Documentation ¶
Overview ¶
Package config handles config files, -config, and env vars at startup.
Index ¶
Constants ¶
const ( DEFAULT_CONFIG_FILES = "/etc/spinc/spinc.yaml,~/.spinc.yaml" DEFAULT_ADDR = "http://127.0.0.1:32308" DEFAULT_TIMEOUT = 5000 // 5s )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandLine ¶
CommandLine represents options (--addr, etc.) and commands (start, etc.). The caller is expected to copy and use the embedded structs separately, like:
var o config.Options = cmdLine.Options var c config.Command = cmdLine.Command
Some commands and options are mutually exclusive, like --ping and --version. Others can be used together, like --addr and --timeout with any command.
func ParseCommandLine ¶
func ParseCommandLine(def Options) CommandLine
ParseCommandLine parses the command line and env vars. Command line options override env vars. Default options are used unless overridden by env vars or command line options. Defaults are usually parsed from config files.
type Options ¶
type Options struct { Addr string `arg:"env:SPINC_ADDR" yaml:"addr"` Config string `arg:"env:SPINC_CONFIG"` Debug bool `arg:"env:SPINC_DEBUG" yaml:"debug"` Env string `arg:"env:SPINC_ENV" yaml:"env"` Help bool Timeout uint `arg:"env:SPINC_TIMEOUT" yaml:"timeout"` Version bool }
Options represents typical command line options: --addr, --config, etc.