Versions in this module Expand all Collapse all v1 v1.0.0 Aug 25, 2026 Changes in this version + var ErrCanceled = errors.New("cli execution canceled") + var ErrCleanup = errors.New("cli cleanup error") + var ErrCommand = errors.New("cli command error") + var ErrCompletion = errors.New("cli completion error") + var ErrDeadline = errors.New("cli execution deadline exceeded") + var ErrHelp = errors.New("cli help requested") + var ErrInternal = errors.New("cli internal error") + var ErrMalformedValue = errors.New("cli malformed value error") + var ErrMissingValue = errors.New("cli missing option value") + var ErrOutput = errors.New("cli output error") + var ErrSignal = errors.New("shutdown signal received") + var ErrUnknownCommand = errors.New("cli unknown command") + var ErrUnknownOption = errors.New("cli unknown option") + var ErrUsage = errors.New("cli usage error") + var ErrValidation = errors.New("cli validation error") + var ErrVersion = errors.New("cli version requested") + type Application struct + func Compile(root *Command, options ...CompileOption) (*Application, error) + func (application *Application) Complete(ctx context.Context, argv []string) ([]CompletionCandidate, error) + func (application *Application) Completion(shell Shell) (string, error) + func (application *Application) Help(path []string, options HelpOptions) (string, error) + func (application *Application) ManifestJSON() ([]byte, error) + func (application *Application) Markdown() (string, error) + func (application *Application) Root() CommandMetadata + func (application *Application) Run(ctx context.Context, request Request) Result + func (application *Application) RunCommand(ctx context.Context, request Request) Result + type Argument struct + func DurationArgument(name string) *Argument[time.Duration] + func EnumArgument(name string, values ...string) *Argument[string] + func FloatArgument(name string) *Argument[float64] + func IntArgument(name string) *Argument[int64] + func StringArgument(name string) *Argument[string] + func StringsArgument(name string) *Argument[[]string] + func TimeArgument(name, layout string) *Argument[time.Time] + func TypedArgument[T any](name, valueType string, parser Parser[T]) *Argument[T] + func UintArgument(name string) *Argument[uint64] + func (argument *Argument[T]) Completion(provider CompletionProvider) *Argument[T] + func (argument *Argument[T]) Description(description string) *Argument[T] + func (argument *Argument[T]) Get(input Input) T + func (argument *Argument[T]) Optional() *Argument[T] + func (argument *Argument[T]) Remainder() *Argument[T] + func (argument *Argument[T]) Secret() *Argument[T] + func (argument *Argument[T]) State(input Input) ValueState + type ArgumentCardinality uint8 + const ArgumentOptional + const ArgumentRemainder + const ArgumentRepeated + const ArgumentRequired + type ArgumentDefinition interface + type Command struct + func NewCommand(name string, options ...CommandOption) *Command + func (command *Command) AddSubcommands(children ...*Command) error + type CommandMetadata struct + func (metadata CommandMetadata) Aliases() []string + func (metadata CommandMetadata) Children() []CommandMetadata + func (metadata CommandMetadata) Deprecated() string + func (metadata CommandMetadata) Description() string + func (metadata CommandMetadata) Documentation() string + func (metadata CommandMetadata) Examples() []string + func (metadata CommandMetadata) Experimental() bool + func (metadata CommandMetadata) Hidden() bool + func (metadata CommandMetadata) Name() string + func (metadata CommandMetadata) Options() []OptionMetadata + func (metadata CommandMetadata) Replacement() string + func (metadata CommandMetadata) Summary() string + type CommandOption func(*Command) + func WithAliases(aliases ...string) CommandOption + func WithArguments(arguments ...ArgumentDefinition) CommandOption + func WithCleanup(hooks ...Handler) CommandOption + func WithDeprecated(message string) CommandOption + func WithDescription(description string) CommandOption + func WithDocumentation(documentation string) CommandOption + func WithExamples(examples ...string) CommandOption + func WithExperimental(experimental bool) CommandOption + func WithHandler(handler Handler) CommandOption + func WithHidden(hidden bool) CommandOption + func WithInteraction(interaction Interaction) CommandOption + func WithMiddleware(middlewares ...Middleware) CommandOption + func WithMutuallyExclusive(options ...OptionDefinition) CommandOption + func WithOptions(options ...OptionDefinition) CommandOption + func WithPostRun(hooks ...Handler) CommandOption + func WithPreRun(hooks ...Handler) CommandOption + func WithReplacement(path string) CommandOption + func WithRequiredTogether(options ...OptionDefinition) CommandOption + func WithSubcommands(children ...*Command) CommandOption + func WithSummary(summary string) CommandOption + func WithValidation(validations ...Validation) CommandOption + func WithVersion(version string) CommandOption + type CommandSet struct + Commands []CommandSpec + Name string + Version string + type CommandSetApplication struct + func CompileCommandSet(set CommandSet, options ...CompileOption) (*CommandSetApplication, error) + func (application *CommandSetApplication) RunCommand(ctx context.Context, request Request) Result + type CommandSpec struct + Handler Handler + Name string + Options []OptionDefinition + Summary string + type CompileOption func(*compileConfiguration) error + func WithExitCodePolicy(policy ExitCodePolicy) CompileOption + func WithLimits(limits Limits) CompileOption + type CompletionCandidate struct + Description string + Value string + type CompletionProvider func(context.Context, CompletionRequest) ([]CompletionCandidate, error) + type CompletionRequest struct + Command CommandMetadata + Partial string + type Error struct + func (err *Error) Error() string + func (err *Error) Is(target error) bool + func (err *Error) Kind() ErrorKind + func (err *Error) Unwrap() error + type ErrorKind string + const ErrorKindCanceled + const ErrorKindCleanup + const ErrorKindCommand + const ErrorKindCompletion + const ErrorKindDeadline + const ErrorKindHelp + const ErrorKindInternal + const ErrorKindMalformedValue + const ErrorKindMissingValue + const ErrorKindOutput + const ErrorKindUnknownCommand + const ErrorKindUnknownOption + const ErrorKindUsage + const ErrorKindValidation + const ErrorKindVersion + type ExitCodePolicy struct + Canceled int + Command int + Deadline int + Internal int + Usage int + type Handler func(context.Context, Invocation) error + type HelpOptions struct + Width int + type IO struct + Stderr io.Writer + Stdin io.Reader + Stdout io.Writer + type Input struct + type Interaction uint8 + const InteractionForbidden + const InteractionOptional + const InteractionRequired + type Invocation struct + func (invocation Invocation) IO() IO + func (invocation Invocation) Input() Input + func (invocation Invocation) Interactive() bool + func (invocation Invocation) Output() *Output + type Limits struct + MaximumArguments int + MaximumArgumentsPerCommand int + MaximumArgvBytes int + MaximumCommandDepth int + MaximumCommands int + MaximumCompletionBytes int + MaximumCompletionResults int + MaximumMetadataBytes int + MaximumOptionsPerCommand int + type Manifest struct + Commands []ManifestCommand + Name string + Root ManifestCommand + Schema string + Version string + type ManifestArgument struct + AllowedValues []string + Cardinality ArgumentCardinality + Description string + Format string + Name string + Secret bool + Type string + type ManifestCommand struct + Aliases []string + Arguments []ManifestArgument + Commands []ManifestCommand + Deprecated string + Description string + Documentation string + Examples []string + Experimental bool + Hidden bool + InheritedOptions []ManifestOption + Name string + Options []ManifestOption + Path string + Replacement string + Summary string + type ManifestOption struct + AllowedValues []string + Defaulted bool + Description string + Format string + Name string + Persistent bool + Required bool + Secret bool + Short string + Source string + Type string + type Middleware func(context.Context, CommandMetadata, Next) error + type Next func(context.Context) error + type Option struct + func BoolOption(name string) *Option[bool] + func DurationOption(name string) *Option[time.Duration] + func EnumOption(name string, values ...string) *Option[string] + func FloatOption(name string) *Option[float64] + func IntOption(name string) *Option[int64] + func KeyValuesOption(name string) *Option[map[string]string] + func StringOption(name string) *Option[string] + func StringsOption(name string) *Option[[]string] + func TimeOption(name, layout string) *Option[time.Time] + func TypedOption[T any](name, valueType string, parser Parser[T]) *Option[T] + func UintOption(name string) *Option[uint64] + func (option *Option[T]) Completion(provider CompletionProvider) *Option[T] + func (option *Option[T]) Default(value T) *Option[T] + func (option *Option[T]) Description(description string) *Option[T] + func (option *Option[T]) Get(input Input) T + func (option *Option[T]) Persistent() *Option[T] + func (option *Option[T]) Required() *Option[T] + func (option *Option[T]) Secret() *Option[T] + func (option *Option[T]) Short(short rune) *Option[T] + func (option *Option[T]) State(input Input) ValueState + type OptionDefinition interface + type OptionMetadata struct + func (metadata OptionMetadata) AllowedValues() []string + func (metadata OptionMetadata) Format() string + func (metadata OptionMetadata) Name() string + func (metadata OptionMetadata) Persistent() bool + func (metadata OptionMetadata) Secret() bool + func (metadata OptionMetadata) Short() rune + func (metadata OptionMetadata) ValueType() string + type Output struct + func (output *Output) Info(message string) error + func (output *Output) SetData(value any) error + type OutputMode uint8 + const OutputHuman + const OutputJSON + const OutputQuiet + type OutputPolicy struct + Mode OutputMode + NoColor bool + Width int + type Parser func(string) (T, error) + type Request struct + Args []string + NonInteractive bool + Output OutputPolicy + Stderr io.Writer + Stdin io.Reader + Stdout io.Writer + type Result struct + Command CommandMetadata + Err error + ExitCode int + type Shell string + const ShellBash + const ShellFish + const ShellPowerShell + const ShellZsh + type ShutdownAction uint8 + const ShutdownAlreadyForced + const ShutdownForced + const ShutdownGraceful + type ShutdownController struct + func NewShutdownController(parent context.Context) (*ShutdownController, error) + func (controller *ShutdownController) Close() + func (controller *ShutdownController) Context() context.Context + func (controller *ShutdownController) Forced() <-chan struct{} + func (controller *ShutdownController) Signal(cause error) ShutdownAction + type Validation func(context.Context, Input) error + type ValueState uint8 + const ValueDefaulted + const ValueExplicit + const ValueOmitted