hgconfig

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2015 License: MIT Imports: 4 Imported by: 6

README

go-hgconfig

Read Mercurial configuration (hg config) values in Go.

Useful for finding out config values such as ui.username.

wercker status GoDoc

Install

go get gopkg.in/nishanths/go-hgconfig.v1

Import it as:

import gopkg.in/nishanths/go-hgconfig.v1

and refer to it as hgconfig.

Test

Tests can be found in go_hgconfig_test.go. To run tests, install ginkgo and gomega, then run:

go test

Usage

package main

import (
    "fmt"
    "gopkg.in/nishanths/go-hgconfig.v1"
)

func main() {
    value, _ := hgconfig.Get("ui.username")
    fmt.Println(value)
}

An example can also be found at example/main.go, and can be run using go run example/main.go.

Functions

Get

Get lets you read a hg config value by name.

value, _, := hgconfig.Get("merge-tools.editmerge.premerge")
Username

Username is a convenience function for getting the config value for ui.username. This is the same as calling hgconfig.Get("ui.username").

username, _, := hgconfig.Username()

Contributing

Pull requests for new features are welcome!

License

go-hgconfig is licensed under the MIT License

Documentation

Overview

hgconfig provides methods to read Mercurial config items by name. It returns the results normally obtained from running "hg config [name]"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(name string) (string, error)

Get lets you read a hg config value by name. It returns the value returned by "hg config [name]" for the given name. If there was an error finding the name, a non-nil error is returned.

func Username

func Username() (string, error)

Username is a convenience function for getting "ui.username". This is the same as calling Get("ui.username").

Types

type ErrNameDoesNotExist

type ErrNameDoesNotExist struct {
	Name string
}

ErrNameDoesNotExist is returned when a queried name is not found by "hg config"

func (*ErrNameDoesNotExist) Error

func (err *ErrNameDoesNotExist) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL