Documentation
¶
Overview ¶
Package cli is the small command framework behind the ypy binary: an explicit list of subcommands, a usage printer and a flag parser that accepts flags and positional arguments in any order.
There is no global registry: cmd/ypy builds the App value and passes it the commands, so what the binary can do is readable in one place.
Index ¶
Constants ¶
View Source
const ( ExitOK = 0 // nothing to report ExitFailure = 1 // the command ran and found a problem (findings, drift, over budget) ExitUsage = 2 // bad flags, unreadable input ExitInternal = 70 )
Exit codes shared by every subcommand.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Command ¶
type Command struct {
Name string
Summary string
// Run executes the command with the arguments that follow its name and
// returns the process exit code.
Run func(ctx context.Context, args []string, io IO) int
}
Command is one subcommand of the binary.
type IO ¶
type IO struct {
Out io.Writer
Err io.Writer
In io.Reader
Env func(key string) string
IsTTY bool
// Dir is the working directory used to resolve relative paths; empty means
// the process working directory.
Dir string
}
IO is what a command may touch: it never reads os.Stdout or os.Getenv directly, so tests run commands in memory.
Click to show internal directories.
Click to hide internal directories.