Documentation
¶
Overview ¶
Package output provides formatted terminal output utilities for the CLI.
This package offers consistent styling for success messages, errors, warnings, informational text, headers, key-value pairs, and tables. All output includes appropriate color coding for better readability in terminal environments.
Example Usage ¶
output.Success("Operation completed")
output.Warning("Something looks off: %v", err)
output.KeyValue("Status", "Running")
output.Table([]string{"ID", "Name"}, rows)
Index ¶
- func Bytes(value int64) string
- func Configure(stdout, stderr io.Writer, jsonMode, noColor bool, label string)
- func Confirm(ctx context.Context, input io.Reader, out io.Writer, label string) (bool, error)
- func CoordinatedWriter(w io.Writer) io.Writer
- func Copy(ctx context.Context, dst io.Writer, src io.Reader, total int64, label string, ...) (int64, error)
- func Header(format string, a ...any)
- func Info(format string, a ...any)
- func IsTerminal(value any) bool
- func KeyValue(key string, value any)
- func ReadWithContext[T any](ctx context.Context, input io.Reader, read func(io.Reader) (T, error)) (T, error)
- func Secret(ctx context.Context, input io.Reader, out io.Writer, label, flagName string) (string, error)
- func Showing(shown int, total int64, label string)
- func StartLoading(ctx context.Context) *tracker
- func StartTracker(ctx context.Context, out io.Writer, enabled bool, labels ...string) *tracker
- func Stderr() io.Writer
- func Stdout() io.Writer
- func Success(format string, a ...any)
- func SuspendProgress() func()
- func Table(headers []string, rows [][]string) error
- func TintEnabled(value string) string
- func TintInsecure(value string) string
- func TintStatus(value string) string
- func TintYesNo(value string) string
- func UnsignedBytes(value uint64) string
- func Warning(format string, a ...any)
- func WriteError(w io.Writer, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Configure ¶ added in v2.15.0
Configure binds output to the current command's writers and output mode.
func Confirm ¶ added in v2.15.0
Confirm uses a terminal selector, falling back to line input for scripts.
func CoordinatedWriter ¶ added in v2.15.0
CoordinatedWriter clears loading while another writer uses the terminal.
func Copy ¶ added in v2.15.0
func Copy(ctx context.Context, dst io.Writer, src io.Reader, total int64, label string, enabled bool) (int64, error)
Copy copies a transfer while reporting bytes, or activity for unknown totals.
func Header ¶
Header prints a purple section heading. Use this to introduce sections of output. The message is prefixed with a newline for visual separation.
func Info ¶
Info prints an info message in purple. The message is prefixed with a newline for visual separation. Format specifiers and arguments work like fmt.Printf.
func IsTerminal ¶ added in v2.15.0
IsTerminal checks the actual writer, including terminal capability.
func KeyValue ¶
KeyValue prints a key-value pair with the muted aligned labels and neutral values. This is useful for displaying structured information like image details or configuration values.
func ReadWithContext ¶ added in v2.15.0
func ReadWithContext[T any](ctx context.Context, input io.Reader, read func(io.Reader) (T, error)) (T, error)
ReadWithContext reads input until read returns or ctx is canceled. Pipes, sockets and terminals are interrupted in place; regular files never block; other readers fall back to readAsyncInternal.
func Secret ¶ added in v2.15.0
func Secret(ctx context.Context, input io.Reader, out io.Writer, label, flagName string) (string, error)
Secret reads a masked value from a terminal, or one line from piped input. An empty value asks the caller to pass flagName instead.
func StartLoading ¶ added in v2.15.0
StartLoading tracks the current command while a request is in progress.
func StartTracker ¶ added in v2.15.0
StartTracker renders a checklist only for interactive text output.
func Success ¶
Success prints a success message in green. The message is prefixed with a newline for visual separation. Format specifiers and arguments work like fmt.Printf.
func SuspendProgress ¶ added in v2.15.0
func SuspendProgress() func()
SuspendProgress pauses every active tracker until the returned function runs.
func Table ¶
Table prints a formatted table with headers and rows. Rendering uses Lip Gloss table styles with zebra-striped rows.
func TintEnabled ¶
TintEnabled applies tints for enabled/disabled values.
func TintInsecure ¶
TintInsecure applies warning tints for insecure values.
func TintStatus ¶
TintStatus applies semantic status coloring to a value.
func UnsignedBytes ¶ added in v2.6.0
UnsignedBytes renders an unsigned byte count in human-readable form.
func Warning ¶
Warning prints a warning message in yellow. The message is prefixed with a newline for visual separation. Format specifiers and arguments work like fmt.Printf.
func WriteError ¶ added in v2.15.0
WriteError renders the command error once through Fang's error handler.
Types ¶
This section is empty.