cliconfig

package
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2015 License: MIT Imports: 11 Imported by: 23

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CLISpecialNameRegex = regexp.MustCompile(`(arg):(\d+)`)

Functions

func Load

func Load(c *cli.Context, cfg interface{}) error

A shortcut for loading a config from the CLI

func NormalizeFilePath

func NormalizeFilePath(path string) string

Replaces ~/ with the users home directory, ./ with the woring directory, and replaces any parses any environment variables.

Types

type File

type File struct {
	// The path to the file
	Path string

	// A map of key/values that was loaded from the file
	Config map[string]string
}

func (File) AbsolutePath

func (f File) AbsolutePath() string

func (File) Exists

func (f File) Exists() bool

func (*File) Load

func (f *File) Load() error

type Loader

type Loader struct {
	// The context that is passed when using a codegangsta/cli action
	CLI *cli.Context

	// The struct that the config values will be loaded into
	Config interface{}

	// A slice of paths to files that should be used as config files
	DefaultConfigFilePaths []string

	// The file that was used when loading this configuration
	File *File
}

func (Loader) Errorf

func (l Loader) Errorf(format string, v ...interface{}) error

func (*Loader) Load

func (l *Loader) Load() error

Loads the config from the CLI and config files that are present.

Jump to

Keyboard shortcuts

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