Documentation ¶
Overview ¶
Package cli contains initialisation functions for go-flags and go-logging. It facilitates sharing them between several projects.
Index ¶
- func ActiveCommand(command *flags.Command) string
- func InitFileLogging(stderrVerbosity, fileVerbosity Verbosity, filename string) error
- func InitLogging(verbosity Verbosity)
- func MustInitFileLogging(stderrVerbosity, fileVerbosity Verbosity, filename string)
- 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{}) string
- type ByteSize
- type CompletionHandler
- type Duration
- type Verbosity
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 InitFileLogging ¶ added in v1.1.0
InitFileLogging initialises logging backends, both to stderr and to a file. If the file path is empty then it will be ignored.
func MustInitFileLogging ¶ added in v1.1.0
MustInitFileLogging is like InitFileLogging but dies on any errors.
func ParseFlags ¶
func ParseFlags(appname string, data interface{}, args []string, opts flags.Options, completionHandler CompletionHandler) (*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 ¶
ParseFlagsFromArgsOrDie is similar to ParseFlagsOrDie but allows control over the flags passed. It returns the active command if there is one.
func ParseFlagsOrDie ¶
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.
Types ¶
type ByteSize ¶ added in v1.3.0
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 ¶ added in v1.3.0
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 ¶ added in v1.2.0
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 ¶ added in v1.2.0
UnmarshalFlag implements the flags.Unmarshaler interface.
func (*Duration) UnmarshalText ¶ added in v1.2.0
UnmarshalText implements the encoding.TextUnmarshaler interface
type Verbosity ¶
type Verbosity logging.Level
A Verbosity is used as a flag to define logging verbosity.
MaxVerbosity is the maximum verbosity we support.
MinVerbosity is the maximum verbosity we support.
func (*Verbosity) UnmarshalFlag ¶
UnmarshalFlag implements flag parsing. It accepts input in three forms: As an integer level, -v 4 (where -v 1 == warning & error only) As a named level, -v debug As a series of flags, -vvv (but note that bare -v does *not* work)