Documentation ¶
Overview ¶
Package flags defines command-line flags to make them consistent between binaries. Not all flags make sense for all binaries.
Index ¶
- Variables
- func Args() []string
- func Parse(defaultList []string, extras ...string)
- func ParseArgs(args, defaultList []string, extras ...string)
- func ParseArgsInto(fs *flag.FlagSet, args, defaultList []string, extras ...string)
- func ParseInto(fs *flag.FlagSet, defaultList []string, extras ...string)
- func Register(names ...string)
- func RegisterInto(fs *flag.FlagSet, names ...string)
Constants ¶
This section is empty.
Variables ¶
var ( // Config ("config") names the configuration file to use. Config = defaultConfigFile // ServerConfigFile is the server configuration file ServerConfigFile = defaultServerConfigFile // HTTPAddr ("http") is the network address on which to listen for // incoming insecure network connections. HTTPAddr = defaultHTTPAddr // Store is the store to target. Store = "default" // Log ("log") sets the level of logging (implements flag.Value). Log logFlag // Audit ("audit") request that an audit of the inventory is performed // when initializing. Audit = false // ResetDB ("dbreset") resets the inventory database ResetDB = false // Simulate ("simulate") enable simulation Simulate = false // EmulateDevices ("emulate-dev") enable emulation of devices EmulateDevices = false // Version causes the program to print its release version and exit. // The printed version is only meaningful in released binaries. Version = false )
var Client = []string{
"config", "log", "store",
}
Client is the set of flags most useful in clients. It can be passed as the argument to Parse to set up the package for a client.
var None = []string{}
None is the set of no flags. It is rarely needed as most programs use either the Server or Client set.
var Server = []string{
"log", "simulate", "emulate-dev", "dbreset", "audit", "serverconfig",
}
Server is the set of flags most useful in servers. It can be passed as the argument to Parse to set up the package for a server.
Functions ¶
func Args ¶
func Args() []string
Args returns a slice of -flag=value strings that will recreate the state of the flags. Flags set to their default value are elided.
func Parse ¶
Parse registers the command-line flags for the given default flags list, plus any extra flag names, and calls flag.Parse. Passing no flag names in either list registers all flags. Passing an unknown name triggers a panic. The Server and Client variables contain useful default sets.
Examples:
flags.Parse(flags.Client) // Register all client flags. flags.Parse(flags.Server, "cachedir") // Register all server flags plus cachedir. flags.Parse(nil) // Register all flags. flags.Parse(flags.None, "config", "endpoint") // Register only config and endpoint.
func ParseArgs ¶
ParseArgs is the same as Parse but uses the provided argument list instead of those provided on the command line. For ParseArgs, the initial command name should not be provided.
func ParseArgsInto ¶
ParseArgsInto is the same as ParseArgs but accepts a FlagSet argument instead of using the default flag.CommandLine FlagSet.
func ParseInto ¶
ParseInto is the same as Parse but accepts a FlagSet argument instead of using the default flag.CommandLine FlagSet.
func Register ¶
func Register(names ...string)
Register registers the command-line flags for the given flag names. Unlike Parse, it may be called multiple times. Passing zero names install all flags. Passing an unknown name triggers a panic.
For example:
flags.Register("config", "endpoint") // Register Config and Endpoint.
or
flags.Register() // Register all flags.
func RegisterInto ¶
RegisterInto is the same as Register but accepts a FlagSet argument instead of using the default flag.CommandLine FlagSet.
Types ¶
This section is empty.