flags

package
v5.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2023 License: Apache-2.0 Imports: 11 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveCommand

func ActiveCommand(command *flags.Command) string

ActiveCommand returns the name of the currently active command.

func ActiveFullCommand added in v5.1.0

func ActiveFullCommand(command *flags.Command) string

ActiveCommand returns the concatenation of all subcommands that make up the command.

func ContainsString added in v5.2.0

func ContainsString(needle string, haystack []string) bool

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.

func ReadStdin added in v5.2.0

func ReadStdin() <-chan string

ReadStdin reads a sequence of space-delimited words from standard input. Words are pushed onto the returned channel asynchronously.

Types

type AdditionalUsageInfo

type AdditionalUsageInfo func(parser *flags.Parser, wr io.Writer)

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

func (b *ByteSize) UnmarshalFlag(in string) error

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

type Duration time.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

func (d *Duration) UnmarshalFlag(in string) error

UnmarshalFlag implements the flags.Unmarshaler interface.

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL