cli

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoHelpRequested = errors.New("no help requested")

ErrNoHelpRequested returns when request for help help does not include the short nor the long option.

Functions

func HandleHelp

func HandleHelp(appName string, req *cmds.Request, out io.Writer) error

HandleHelp writes help to a writer for the given request's command.

func LongHelp

func LongHelp(rootName string, root *cmds.Command, path []string, out io.Writer) error

LongHelp writes a formatted CLI helptext string to a Writer for the given command

func Parse

func Parse(ctx context.Context, input []string, stdin *os.File, root *cmds.Command) (*cmds.Request, error)

Parse parses the input commandline string (cmd, flags, and args). returns the corresponding command Request object.

This function never returns nil, even on error.

func Run

func Run(ctx context.Context, root *cmds.Command,
	cmdline []string, stdin, stdout, stderr *os.File,
	buildEnv cmds.MakeEnvironment, makeExecutor cmds.MakeExecutor) error

func ShortHelp

func ShortHelp(rootName string, root *cmds.Command, path []string, out io.Writer) error

ShortHelp writes a formatted CLI helptext string to a Writer for the given command

Types

type Closer

type Closer interface {
	Close()
}

Closer is a helper interface to check if the env supports closing

type ExitError

type ExitError int

ExitError is the error used when a specific exit code needs to be returned.

func (ExitError) Error

func (e ExitError) Error() string

type ResponseEmitter

type ResponseEmitter interface {
	cmds.ResponseEmitter

	Stdout() io.Writer
	Stderr() io.Writer

	// SetStatus sets the exit status for this command.
	SetStatus(int)

	// Status returns the exit status for the command.
	Status() int
}

ResponseEmitter extends cmds.ResponseEmitter to give better control over the command line

func NewResponseEmitter

func NewResponseEmitter(stdout, stderr io.Writer, req *cmds.Request) (ResponseEmitter, error)

NewResponseEmitter constructs a new response emitter that writes results to the console.

Jump to

Keyboard shortcuts

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