Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Argument ¶
type Argument struct {
// Name of the argument, which must match the regular expression `^[a-z][a-z0-9]*$` and be unique in arguments of the command which the argument belongs to.
// This property is required.
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// Description of the argument.
// The default value is an empty string.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// Type of the value that is assignable to the argument.
// The default value is "string".
Type Type `json:"type,omitempty" yaml:"type,omitempty"`
// Whether the argument is variadic (i.e. can have zero or more values).
// It can be true only if this argument is the last argument in the arguments of the belonging command.
// The default value is false.
Variadic bool `json:"variadic,omitempty" yaml:"variadic,omitempty"`
}
Argument represents a positional required argument in command line arguments.
type Command ¶
type Command struct {
// Description of the command.
// The default value is an empty string.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// A collection of options, which is a mapping from option names to options.
// The default value is an empty object.
// A property name is a name of an option, which must match the regular expression `^(-[a-z][a-z0-9]*)+$` and be unique in options of the command.
Options map[string]Option `json:"options,omitempty" yaml:"options,omitempty"`
// A list of arguments.
// The default value is an empty array.
Arguments []Argument `json:"arguments,omitempty" yaml:"arguments,omitempty"`
// A collection of subcommands, which is a mapping from subcommand names to child commands.
// The default value is an empty object.
// A property name is a name of a subcommand, which must match the regular expression `^[a-z][a-z0-9]*$` and be unique in subcommands of the command.
Subcommands map[string]Command `json:"subcommands,omitempty" yaml:"subcommands,omitempty"`
}
Command represents a root command or a subcommand of the program. It may have options, arguments, and subcommands recursively.
type Option ¶
type Option struct {
// Short name of the option, which must match the regular expression `^-[a-z]$` and be unique in options of the command which the option belongs to.
// If short is not specified then short name for this option is not available.
Short string `json:"short,omitempty" yaml:"short,omitempty"`
// Description of the option.
// The default value is an empty string.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// Type of the value that is assignable to this option.
// The default value is "string".
Type Type `json:"type,omitempty" yaml:"type,omitempty"`
// Whether the option of typed boolean has a negated version.
// If true then the option can be specified with a negation prefix `-no` in the command line arguments.
// The default value is false.
Negation bool `json:"negation,omitempty" yaml:"negation,omitempty"`
// String value representing the default value of the option.
// It must be a string that can be parsed as a value of the option type.
// If not specified, the following values corresponding to the option type.
// - boolean: "false"
// - string: ""
// - integer: "0"
Default string `json:"default,omitempty" yaml:"default,omitempty"`
// Whether the option can be specified multiple times.
// If true then the option can be specified multiple times in the command line arguments.
// The default value is false.
Repeated bool `json:"repeated,omitempty" yaml:"repeated,omitempty"`
// Whether the option propagates to subcommands.
// If true then the option is available in all subcommands of the command which the option belongs to.
// The default value is false.
Propagates bool `json:"propagates,omitempty" yaml:"propagates,omitempty"`
}
Option represents an optional argument in command line arguments.
type PathCommand ¶
type Program ¶
type Program struct {
// Name of the program.
// The default value is an empty string.
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// Version of the program.
// The default value is an empty string.
Version string `json:"version,omitempty" yaml:"version,omitempty"`
// Embedded Command fields
Command `yaml:",inline"`
}
Program is a root command that may have a name and a version. It consists of commands recursively.
type Schema ¶
type Schema struct {
Program Program
// contains filtered or unexported fields
}
func (Schema) ListCommand ¶
func (s Schema) ListCommand() (commands []PathCommand)
func (Schema) PropagateOptions ¶
PropagateOptions creates a deep copy of the Schema.
Click to show internal directories.
Click to hide internal directories.