Documentation
¶
Overview ¶
Package flagx extends to capabilities of flags to also be able to read from environment variables. This comes in handy when dockerizing applications.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArgsFromEnv ¶
ArgsFromEnv will expand command-line argument parsing to include setting the values of flags from their corresponding environment variables. The environment variable for an argument is the upper-case version of the command-line flag.
Types ¶
type FileBytes ¶
type FileBytes []byte
FileBytes is a new flag type. It automatically reads the content of the given filename as a `[]byte`, handling errors during flag parsing.
func (FileBytes) Get ¶
func (fb FileBytes) Get() interface{}
Get retrieves the bytes read from the file (or the default bytes).
func (*FileBytes) Set ¶
Set accepts a filename and reads the bytes associated with that file into the FileBytes storage.
func (FileBytes) String ¶
String reports the FileBytes content as a string.
FileBytes are awkward to represent in help text, and such help text is the main use of the Stringer interface for this flag. Help text like:
"Sets the file containing the prefix string. The default file contents are: " + fb.String()
is recommended.
type StringArray ¶
type StringArray []string
StringArray is a new flag type. It appends the flag parameter to an `[]string` allowing the parameter to be specified multiple times. Unlike other Flag types, the default argument should almost always be the empty array, because there is no way to remove an element, only to add one.
func (StringArray) Get ¶
func (sa StringArray) Get() interface{}
Get retrieves the value contained in the flag.
func (*StringArray) Set ¶
func (sa *StringArray) Set(s string) error
Set accepts a string parameter and appends it to the associated StringArray.
func (StringArray) String ¶
func (sa StringArray) String() string
String reports the StringArray as a Go value.