command

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: MIT Imports: 6 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name        string   `yaml:"name" json:"name" jsonschema_description:"Name of the command"`
	Aliases     []string `yaml:"aliases,omitempty" json:"aliases,omitempty" jsonschema_description:"Aliases of the command"`
	Description string   `yaml:"description,omitempty" json:"description,omitempty" jsonschema_description:"Description of the command"`
	Group       string   `yaml:"group,omitempty" json:"group,omitempty" jsonschema_description:"Group of the command"`
	Hidden      bool     `yaml:"hidden,omitempty" json:"hidden,omitempty" jsonschema_description:"Hidden state of the command"`
	Parsing     Parsing  `` /* 174-byte string literal not displayed */

	Flags           FlagSet    `yaml:"flags,omitempty" json:"flags,omitempty" jsonschema_description:"Flags of the command with their description"`
	PersistentFlags FlagSet    `` /* 145-byte string literal not displayed */
	ExclusiveFlags  [][]string `yaml:"exclusiveflags,omitempty" json:"exclusiveflags,omitempty" jsonschema_description:"Flags that are mutually exclusive"`
	Run             Run        `` /* 149-byte string literal not displayed */
	Completion      struct {
		Flag          map[string][]string `yaml:"flag,omitempty" json:"flag,omitempty" jsonschema_description:"Flag completion"`
		Positional    [][]string          `yaml:"positional,omitempty" json:"positional,omitempty" jsonschema_description:"Positional completion"`
		PositionalAny []string            `` /* 133-byte string literal not displayed */
		Dash          [][]string          `yaml:"dash,omitempty" json:"dash,omitempty" jsonschema_description:"Dash completion"`
		DashAny       []string            `yaml:"dashany,omitempty" json:"dashany,omitempty" jsonschema_description:"Dash completion of every other position"`
	} `yaml:"completion,omitempty" json:"completion,omitzero" jsonschema_description:"Completion definition"`
	Commands []Command `yaml:"commands,omitempty" json:"commands,omitempty" jsonschema_description:"Subcommands of the command"`

	Documentation struct {
		Command       string            `yaml:"command,omitempty" json:"command,omitempty" jsonschema_description:"Documentation of the command"`
		Flag          map[string]string `yaml:"flag,omitempty" json:"flag,omitempty" jsonschema_description:"Documentation of flags"`
		Positional    []string          `yaml:"positional,omitempty" json:"positional,omitempty" jsonschema_description:"Documentation of positional arguments"`
		PositionalAny string            `` /* 130-byte string literal not displayed */
		Dash          []string          `yaml:"dash,omitempty" json:"dash,omitempty" jsonschema_description:"Documentation of dash arguments"`
		DashAny       string            `yaml:"dashany,omitempty" json:"dashany,omitempty" jsonschema_description:"Documentation of other dash arguments"`
	} `yaml:"documentation,omitempty" json:"documentation,omitzero" jsonschema_description:"Documentation"`
	Examples map[string]string `yaml:"examples,omitempty" json:"examples,omitempty" jsonschema_description:"Examples"`
}

func (*Command) AddFlag

func (c *Command) AddFlag(f Flag)

type Extended added in v1.4.0

type Extended struct {
	Description string `yaml:"description,omitempty" json:"description,omitempty" jsonschema_description:"Description of the flag"`
	Nargs       int    `yaml:"nargs,omitempty" json:"nargs,omitempty" jsonschema_description:"Amount of arguments consumed"`
}

type Flag

type Flag struct {
	Longhand    string
	Shorthand   string
	Description string

	NameAsShorthand bool
	Repeatable      bool
	Optarg          bool
	Value           bool
	Hidden          bool
	Required        bool
	Persistent      bool

	Nargs int
}

func (Flag) Name added in v1.4.0

func (f Flag) Name() string

type FlagSet added in v1.4.0

type FlagSet map[string]Flag

func (FlagSet) MarshalYAML added in v1.4.0

func (fs FlagSet) MarshalYAML() (any, error)

func (*FlagSet) UnmarshalYAML added in v1.4.0

func (fs *FlagSet) UnmarshalYAML(value *yaml.Node) error

type Parsing

type Parsing string
const (
	DEFAULT          Parsing = ""                 // INTERSPERSED but allows implicit changes
	INTERSPERSED     Parsing = "interspersed"     // mixed flags and positional arguments
	NON_INTERSPERSED Parsing = "non-interspersed" // flag parsing stopped after first positional argument
	DISABLED         Parsing = "disabled"         // flag parsing disabled
)

type Run added in v1.3.0

type Run string

func Alias added in v1.3.0

func Alias(s ...string) (Run, error)

func (Run) Type added in v1.3.0

func (r Run) Type() string

func (*Run) UnmarshalYAML added in v1.3.0

func (r *Run) UnmarshalYAML(value *yaml.Node) error

Jump to

Keyboard shortcuts

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