Documentation
¶
Index ¶
- func ActiveCommand(command *flags.Command) string
- func ActiveFullCommand(command *flags.Command) string
- func ContainsString(needle string, haystack []string) bool
- func ParseFlags(appname string, data interface{}, args []string, opts flags.Options, ...) (*flags.Parser, []string, error)
- func ParseFlagsFromArgsOrDie(appname string, data interface{}, args []string, ...) string
- func ParseFlagsOrDie(appname string, data interface{}, additionalUsageInfo AdditionalUsageInfo) string
- func ReadAllStdin() []string
- func ReadStdin() <-chan string
- type AdditionalUsageInfo
- type ByteSize
- type CompletionHandler
- type Duration
- type StdinStrings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveCommand ¶
ActiveCommand returns the name of the currently active command.
func ActiveFullCommand ¶ added in v5.1.0
ActiveCommand returns the concatenation of all subcommands that make up the command.
func ContainsString ¶ added in v5.2.0
ContainsString returns true if the given slice contains an individual string.
func ParseFlags ¶
func ParseFlags(appname string, data interface{}, args []string, opts flags.Options, completionHandler CompletionHandler, additionalUsageInfo AdditionalUsageInfo) (*flags.Parser, []string, error)
ParseFlags parses the app's flags and returns the parser, any extra arguments, and any error encountered. It may exit if certain options are encountered (eg. --help).
func ParseFlagsFromArgsOrDie ¶
func ParseFlagsFromArgsOrDie(appname string, data interface{}, args []string, additionalUsageInfo AdditionalUsageInfo) string
ParseFlagsFromArgsOrDie is similar to ParseFlagsOrDie but allows control over the flags passed. It returns the active command if there is one.
func ParseFlagsOrDie ¶
func ParseFlagsOrDie(appname string, data interface{}, additionalUsageInfo AdditionalUsageInfo) string
ParseFlagsOrDie parses the app's flags and dies if unsuccessful. Also dies if any unexpected arguments are passed. It returns the active command if there is one.
func ReadAllStdin ¶ added in v5.2.0
func ReadAllStdin() []string
ReadAllStdin reads standard input in its entirety to a slice. Since this reads it completely before returning it won't handle a slow input very nicely. ReadStdin is therefore preferable when possible.
Types ¶
type AdditionalUsageInfo ¶
AdditionalUsageInfo is the type of function that seeks out auxiliary options and adds them to the end of usage info
type ByteSize ¶
type ByteSize uint64
A ByteSize is used for flags that represent some quantity of bytes that can be passed as human-readable quantities (eg. "10G").
func (*ByteSize) UnmarshalFlag ¶
UnmarshalFlag implements the flags.Unmarshaler interface.
type CompletionHandler ¶
type CompletionHandler func(parser *flags.Parser, items []flags.Completion)
A CompletionHandler is the type of function that our flags library uses to handle completions.
type Duration ¶
A Duration is used for flags that represent a time duration; it's just a wrapper around time.Duration that implements the flags.Unmarshaler and encoding.TextUnmarshaler interfaces.
func (*Duration) UnmarshalFlag ¶
UnmarshalFlag implements the flags.Unmarshaler interface.
func (*Duration) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface
type StdinStrings ¶ added in v5.2.0
type StdinStrings []string
StdinStrings is a type used for flags; it accepts a slice of strings but also if it's a single - it reads its contents from stdin.
func (StdinStrings) Get ¶ added in v5.2.0
func (s StdinStrings) Get() []string
Get reads stdin if needed and returns the contents of this slice.