Documentation
¶
Overview ¶
Package output provides structured output formatting for CLI commands. It supports text (default) and JSON output modes, allowing commands to produce machine-readable output for CI/CD pipelines and scripting.
Index ¶
Constants ¶
const ( StatusSuccess = "success" StatusError = "error" StatusWarning = "warning" )
Status constants for the Response envelope.
Variables ¶
This section is empty.
Functions ¶
func Emit ¶ added in v1.7.0
Emit writes a Response to cmd.OutOrStdout() when --output is "json". It is a no-op when the output format is text or the flag is absent.
func IsJSONOutput ¶ added in v1.7.0
IsJSONOutput returns true if the --output flag on the command is set to "json".
func RenderMarkdown ¶ added in v1.7.0
RenderMarkdown renders markdown content to styled ANSI terminal output via glamour. It detects the terminal width automatically, falling back to 80 columns. If glamour fails for any reason, the original content is returned unchanged.
Types ¶
type Response ¶ added in v1.7.0
type Response struct {
Status string `json:"status"`
Command string `json:"command"`
Data any `json:"data,omitempty"`
Error string `json:"error,omitempty"`
}
Response is the standard JSON envelope for all command output.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer handles formatted output based on the configured format.