Help us shape the future of Go! Take the 2026 Go Developer Survey

cli

package
v0.4.10 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitCode

func ExitCode(err error) int

ExitCode maps command errors to stable process exit codes: 0 success, 1 runtime failure, 2 usage error.

Types

type Command

type Command struct {
	Name     string
	Aliases  []string
	Summary  string
	Usage    string
	Long     string
	Run      RunFunc
	Children []*Command
}

Command describes one CLI command. Commands can be nested arbitrarily.

func (*Command) Execute

func (c *Command) Execute(ctx context.Context, args []string, out, errOut io.Writer) error

Execute routes args through the command tree and handles help consistently.

func (*Command) Help

func (c *Command) Help(w io.Writer)

Help renders stable, human-readable command documentation.

type RunFunc

type RunFunc func(context.Context, []string, io.Writer, io.Writer) error

RunFunc executes a command after command routing and built-in help handling.

type UsageError

type UsageError struct {
	Message string
	Hint    string
}

UsageError represents invalid user input. Callers should exit with code 2.

func (*UsageError) Error

func (e *UsageError) Error() string

Jump to

Keyboard shortcuts

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