Documentation ¶
Overview ¶
Package goflags allows parsing go command invocations and storing their flags in a CommandFlags structure. It also provides utilities to backtrack through the process stack to find and parse the flags of the first parent go command found in the process hierarchy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CommandFlags ¶
type CommandFlags struct { Long map[string]string Short map[string]struct{} Unknown []string // flags we don't process but store anyway }
CommandFlags represents the flags provided to a go command invocation
func ParseCommandFlags ¶
func ParseCommandFlags(wd string, args []string) (CommandFlags, error)
ParseCommandFlags parses a slice representing a go command invocation and returns its flags. Direct arguments to the command are ignored. The value of $GOFLAGS is also included in the returned flags.
func (CommandFlags) Get ¶
func (f CommandFlags) Get(flag string) (val string, found bool)
Get returns the value of the specified long-form flag if present. The name is provided including the leading hyphen, e.g: "-tags".
func (CommandFlags) Slice ¶
func (f CommandFlags) Slice() []string
Slice returns the command flags as a string slice - long flags are returned as a string of the form '-flagName="flagVal"' - short flags are returned as a string of the form '-flagName' - unknow flags and values are ignored
func (CommandFlags) Trim ¶
func (f CommandFlags) Trim(flags ...string)
Trim removes the specified flags and their value from the long and short flags