Documentation
¶
Overview ¶
Package output provides styled messages and terminal tables for the CLI.
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 requires terminal input, using a selector or line input depending on the output terminal.
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. A leading newline separates the heading from previous output.
func Info ¶
Info prints an info message in purple. Format specifiers work like fmt.Printf; a leading newline separates messages.
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. Use it for structured details and 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. Pollable files cancel in place; other blocking readers use an asynchronous read.
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. Format specifiers work like fmt.Printf; a leading newline separates messages.
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. Format specifiers work like fmt.Printf; a leading newline separates messages.
func WriteError ¶ added in v2.15.0
WriteError renders the command error once through Fang's error handler.
Types ¶
This section is empty.