Golang flags parser with zero dependency.
See simple.go for a basic usage.
flags
gives a simple way to get flag's value from argument or environment variable.
Argument takes priority over environment variable. Argument and environment variable names are generated from configuration you pass.
The FlagSet
name is used to prefix all environment variable, replacing -
by _
.
The prefix
name is used then to specialize your flag name (e.g. if you have want to use the same flags
twice, you can change the prefix)
The argument's name is in camelCase format. The environement variable name is in SNAKE_UPPER_CASE format.
Flags can take a default value, that can be overriden programatically, always in the case you reuse the same flags
twice (see advanced.go example.)
Be careful when using the arguments values, if someone list the processes on the system, they will appear in plain-text. Pass secrets by environment variables: it's less easily visible.