Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultParser = &Parser{ After: []string{"server", "agent", "etcd-snapshot:1"}, ConfigFlags: []string{"--config", "-c"}, EnvName: version.ProgramUpper + "_CONFIG_FILE", DefaultConfig: "/etc/" + version.Program + "/config.yaml", ValidFlags: map[string][]cli.Flag{"server": cmds.ServerFlags, "etcd-snapshot": cmds.EtcdSnapshotFlags}, }
Functions ¶
func MustFindString ¶
Types ¶
type Parser ¶
type Parser struct { After []string ConfigFlags []string OverrideFlags []string EnvName string DefaultConfig string // ValidFlags are maps of flags that are valid for that particular conmmand. This enables us to ignore flags in // the config file that do no apply to the current command. ValidFlags map[string][]cli.Flag }
func (*Parser) FindString ¶
func (*Parser) Parse ¶
Parse will parse an os.Args style slice looking for Parser.FlagNames after Parse.After. It will read the parameter value of Parse.FlagNames and read the file, appending all flags directly after the Parser.After value. This means a the non-config file flags will override, or if a slice append to, the config file values. If Parser.DefaultConfig is set, the existence of the config file is optional if not set in the os.Args. This means if Parser.DefaultConfig is set we will always try to read the config file but only fail if it's not found if the args contains Parser.FlagNames
Click to show internal directories.
Click to hide internal directories.