command

package
v0.0.0-...-08cdc8b Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoCmd           = errors.New("no command specified")
	ErrInvalidCmd      = errors.New("invalid command specified")
	ErrFailedCreateCmd = errors.New("command creation failed")
	ErrMultipleCmd     = errors.New("multiple commands specified")
	ErrHelpRequested   = errors.New("help requested")
)

Functions

This section is empty.

Types

type CommandRunner

type CommandRunner interface {
	// Name gets the name of the Command
	Name() string
	// Usage gets the usage string for the Command
	Usage() string
	// Run will run the command and return any errors
	Run() error
}

CommandRunner is an interface for commands, allowing commands to implement the minimum set of requirements to observe and run the command from above. It is used as a return type to allow passing a usable command to the caller after parsing and creating the command implementation

func ParseCLI

func ParseCLI(env environment.Environment) (CommandRunner, error)

ParseCLI parses for a subcommand as the first argument to the calling binary, and initializes the command (if it exists). It also provides the default usage statement.

It does not support flags of its own, each subcommand is responsible for parsing their flags.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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