Documentation
¶
Index ¶
Constants ¶
const ( OnlyShortNoValue = OptionGroup(iota) // -v OnlyShortNoValueOptional // [-v] OtherOptional // [--long=value] Other // --long=value ActionGroup // { --help|--version} OperationGroup // { --browse|--lookup} Hidden )
const ( Bold = ansiterm.Bold Underline = ansiterm.Underline )
const ( ColorData = "_synopsisColor" StyleData = "_synopsisStyle" CategoryData = "_synopsisCategory" )
Variables ¶
This section is empty.
Functions ¶
func ArgCounter ¶
func CategoryFromData ¶ added in v0.19.0
CategoryFromData obtains the synopsis category which was set within the data of a flag, which is the empty string if the flag has no synopsis category.
func Placeholder ¶
Types ¶
type Command ¶
type Command struct {
Name string
Flags map[OptionGroup][]*Flag
Args []*Arg
RequiredArgs []*Arg
OptionalArgs []*Arg
RTL bool
Style Style
// CondenseCategories causes flags with a SynopsisCategory set to be condensed
// into groups
CondenseCategories bool
// Next, when set, continues the synopsis after the args of this command. It is used
// to expand a synopsis through to the form of a sub-command, in which case the args
// of this command stop short of the implicit placeholder for the sub-command.
Next Stringer
// Invocation, when set, is written in place of the name. It is used when
// the command is invoked by a flag rather than by its name.
Invocation string
}
type Expr ¶
type Flag ¶
type Flag struct {
Short string
Shorts []rune
Long string
Primary string // Long if present, otherwise Short
Separator string
Names []string
AlternateNames []string
Value *Value
Group OptionGroup
Style Style
// Category names the synopsis category that the flag belongs to, which is
// empty for most flags. See Command.CondenseCategories.
Category string
OptionalValue bool
}
func (*Flag) WithOptionalValue ¶ added in v0.21.0
type Operation ¶ added in v0.25.0
type Operation struct {
Flag *Flag
Command *Command
// Name, when set, is the name of the command, which is written after the flag.
// This is the case when the flag selects among several commands.
Name string
}
Operation is the synopsis of a pseudo command, which is a command that is invoked by naming a flag. It is written as the name of the flag followed by the flags and args of the command. For a flag that selects among commands, the name of the command follows the flag.
type OptionGroup ¶
type OptionGroup int
type Style ¶ added in v0.17.0
type Style struct {
// contains filtered or unexported fields
}
Style controls how the name of a flag, command, or expression is rendered in the synopsis. The zero value renders the name in Bold. When a color is set, it is used in place of the default Bold style unless a style is also set explicitly, in which case both are applied.
func StyleFromData ¶ added in v0.17.0
type Usage ¶
type Usage struct {
// contains filtered or unexported fields
}