commando

package
v0.0.0-...-2bde968 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Output = io.Writer(os.Stderr)

Output is the Writer where help and errors are printed with regards to command line parsing. It is os.Stderr by default. It should be set before Run.

Functions

func ArgError

func ArgError(err error) error

ArgError is used to wrap an error returned from CommandFunc, in order to signal that the error should be regarded as a command line validation issue. If the error returned by CommandFunc is wrapped like this, help will be printed.

func NewFlagSet

func NewFlagSet(name string) *flag.FlagSet

NewFlagSet creates a new FlagSet with ContinueOnError, and Usage set directly to PrintDefaults.

func Register

func Register(fs *flag.FlagSet, desc string, f CommandFunc)

Register registers the given FlagSet as a command. The command name is fs.Name(). fs should preferably be made by commando.NewFlagSet, but otherwise it should be created with flag.ContinueOnError.

func Run

func Run()

Run will parse the command line flags and run the appropriate command. It will exit the application if a problem occurs, and print help and errors to Output if needed. The usage line is printed by Run, not Usage; keep this in mind when setting Usage.

Types

type CommandFunc

type CommandFunc func() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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