Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCommandError ¶
IsCommandError reports whether any error in err's tree matches CommandError.
Types ¶
type CommandError ¶
type CommandError struct {
Err error
}
CommandError is returned when a command fails because of a user error (unknown command, invalid flag etc.). All other errors comes from the execution of the command.
func (*CommandError) Is ¶
func (*CommandError) Is(e error) bool
Is reports whether e is of type *CommandError.
type Commandeer ¶
type Commandeer struct { Command Commander CobraCommand *cobra.Command Root *Commandeer Parent *Commandeer // contains filtered or unexported fields }
Commandeer holds the state of a command and its subcommands.
type Commander ¶
type Commander interface { Name() string Use() string // Init is called when the cobra command is created. // This is where the flags, short and long description etc. can be added. Init(*Commandeer) error // Args the command args Args(ctx context.Context, cd *Commandeer, args []string) error // PreRun called on all ancestors and the executing command itself, before execution, starting from the root. // This is the place to evaluate flags and set up the this Commandeer. // The runner Commandeer holds the currently running command, which will be PreRun last. PreRun(this, runner *Commandeer) error // Run the command execution. Run(ctx context.Context, cd *Commandeer, args []string) error // Commands returns the sub commands, if any. Commands() []Commander }
Commander is the interface that must be implemented by all commands.
Click to show internal directories.
Click to hide internal directories.