Documentation
¶
Index ¶
- func ExitCode(err error) int
- func IsPresented(err error) bool
- func IsTerminal(w io.Writer) bool
- func Presented(err error) error
- func ReportActivityDetail(w io.Writer, detail string)
- func SuggestClosest(input string, candidates []string) string
- func WithOutputOptions(ctx context.Context, opts OutputOptions) context.Context
- type Command
- type OutputOptions
- type PresentedError
- type RunFunc
- type Terminal
- func (t *Terminal) Activity(ctx context.Context, label string, fn func(io.Writer) error) error
- func (t *Terminal) Diagnostic(format string, args ...any)
- func (t *Terminal) Fail(label, detail string)
- func (t *Terminal) Header(app, environment string)
- func (t *Terminal) Info(label, detail string)
- func (t *Terminal) NonInteractive() bool
- func (t *Terminal) Plain() bool
- func (t *Terminal) Quiet() bool
- func (t *Terminal) Result(state, subject, detail string)
- func (t *Terminal) Section(title string)
- func (t *Terminal) Skip(label, detail string)
- func (t *Terminal) Success(label, detail string)
- func (t *Terminal) TTY() bool
- func (t *Terminal) Verbose() bool
- func (t *Terminal) Warn(label, detail string)
- type UsageError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExitCode ¶
ExitCode maps command errors to stable process exit codes: 0 success, 1 runtime failure, 2 usage error.
func IsPresented ¶ added in v0.4.11
func IsTerminal ¶ added in v0.4.11
func ReportActivityDetail ¶ added in v0.4.11
ReportActivityDetail updates the human-facing detail of an in-flight Activity when w is the activity progress writer. Other writers intentionally ignore it.
func SuggestClosest ¶ added in v0.4.11
func WithOutputOptions ¶ added in v0.4.11
func WithOutputOptions(ctx context.Context, opts OutputOptions) context.Context
WithOutputOptions attaches process-wide human-output preferences to a command context without changing command result models.
Types ¶
type Command ¶
type Command struct {
Name string
Hidden bool
Aliases []string
Summary string
Usage string
Long string
Examples []string
Run RunFunc
Children []*Command
}
Command describes one CLI command. Commands can be nested arbitrarily.
type OutputOptions ¶ added in v0.4.11
type OutputOptions struct {
Quiet bool
Verbose bool
NoColor bool
ReducedMotion bool
Plain bool
NonInteractive bool
}
OutputOptions controls human terminal rendering. Machine-readable command output must remain independent from these settings.
func OutputOptionsFromContext ¶ added in v0.4.11
func OutputOptionsFromContext(ctx context.Context) OutputOptions
OutputOptionsFromContext returns the current human-output preferences.
type PresentedError ¶ added in v0.4.11
type PresentedError struct {
Err error
}
PresentedError marks a failure that was already rendered as a complete human result by the command. The process must still fail, but main must not append a second generic error block.
func (*PresentedError) Error ¶ added in v0.4.11
func (e *PresentedError) Error() string
func (*PresentedError) Unwrap ¶ added in v0.4.11
func (e *PresentedError) Unwrap() error
type Terminal ¶ added in v0.4.11
type Terminal struct {
// contains filtered or unexported fields
}
Terminal renders consistent human-facing CLI output. Primary command results still belong on stdout; activity and diagnostics belong on stderr.
func NewTerminal ¶ added in v0.4.11
func (*Terminal) Activity ¶ added in v0.4.11
Activity runs potentially slow work with delayed progress feedback. It never invents percentages or ETAs. Successful buffered detail is shown only in verbose mode; failed detail is always revealed.
func (*Terminal) Diagnostic ¶ added in v0.4.11
func (*Terminal) NonInteractive ¶ added in v0.4.11
type UsageError ¶
UsageError represents invalid user input. Callers should exit with code 2.
func (*UsageError) Error ¶
func (e *UsageError) Error() string