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.
func ParseConfigFiles ¶
type UserCommandLine ¶ added in v2.0.6
type UserCommandLine struct { UserOptions Command }
type UserOptions ¶ added in v2.0.6
type UserOptions struct { Addr *string Config *string Debug *bool Env *string Help *bool Timeout *uint Version *bool }
An Options record for pulling the originally set user arguments
func ParseUserOptions ¶ added in v2.0.6
func ParseUserOptions(def UserOptions) UserOptions
Parses the Options explictly set on the command line by the user. Used for allowing reporting on command line needed to re-run a command
func (*UserOptions) ToOptions ¶ added in v2.0.6
func (u *UserOptions) ToOptions() Options