Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColorEnabled ¶ added in v3.17.0
func ColorEnabled() bool
ColorEnabled returns false when the NO_COLOR environment variable is present See https://no-color.org for the convention
func ValueOrDash ¶ added in v3.17.0
Types ¶
type Format ¶
type Format string
Format represents the output format type
const ( // FormatJSON outputs in JSON format FormatJSON Format = "json" // FormatYAML outputs in YAML format FormatYAML Format = "yaml" // FormatText outputs in plain text/default format FormatText Format = "text" DefaultFormat Format = FormatJSON )
func ResolveFormat ¶ added in v3.22.0
ResolveFormat determines the output format to use. Priority: flagValue (if set) > configValue > DefaultFormat
type Formatter ¶
type Formatter interface {
// TextOutput returns the plain text representation
TextOutput() string
}
Formatter is an interface that types must implement to support formatted output
type OutputFlags ¶ added in v3.29.0
type OutputFlags struct {
JSON bool `help:"Output as JSON" xor:"format"`
YAML bool `help:"Output as YAML" xor:"format"`
Text bool `help:"Output as text" xor:"format"`
Output string `help:"Output format. One of: json, yaml, text" short:"o" default:"${output_default_format}" enum:",json,yaml,text"`
}
OutputFlags provides shorthand flags for output format selection. Embed this struct in command structs to get --json, --yaml, --text flags in addition to the existing --output/-o flag.
func (*OutputFlags) AfterApply ¶ added in v3.29.0
func (o *OutputFlags) AfterApply() error
AfterApply is called by Kong after parsing to map boolean flags to the Output string.
type Viewable ¶ added in v3.17.0
Viewable wraps any type to provide formatted output support. It delegates JSON/YAML marshaling directly to the underlying data, while using a custom render function for text output.
func (Viewable[T]) MarshalJSON ¶ added in v3.17.0
MarshalJSON delegates JSON marshaling to the underlying data.
func (Viewable[T]) MarshalYAML ¶ added in v3.17.0
MarshalYAML delegates YAML marshaling to the underlying data.
func (Viewable[T]) TextOutput ¶ added in v3.17.0
TextOutput implements the Formatter interface for text output.