Documentation
¶
Overview ¶
Package clix provides CLI convenience functions for Frostyard tools, wrapping charmbracelet/fang and spf13/cobra with standardized version injection, common flags, JSON output helpers, and reporter factory.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( JSONOutput bool // --json flag value Verbose bool // --verbose / -v flag value DryRun bool // --dry-run / -n flag value Silent bool // --silent / -s flag value )
Common flag values, populated when Run() registers persistent flags.
Functions ¶
func BindViper ¶
BindViper binds the common flags (--json, --verbose, --dry-run) to viper. Call this in a PersistentPreRunE if your app uses viper for config management.
func NewReporter ¶
NewReporter returns the appropriate reporter based on the Silent and JSONOutput flags. Silent mode: NoopReporter (suppresses all output). Silent takes priority over JSON. JSON mode: JSONReporter writing to os.Stdout (for piping/parsing). Text mode: TextReporter writing to os.Stderr (keeps stdout clean for data).
func OutputJSON ¶
OutputJSON writes data as indented JSON to stdout if JSONOutput is true. Returns true if output was written, false if JSON mode is not active. If encoding fails, a fallback error envelope is written to stdout and the encoding error is returned alongside true (output was still written).
func OutputJSONError ¶
OutputJSONError writes a structured error object as JSON to stdout and returns a wrapped error for the caller to propagate. If err is nil, the message alone is used as the error text.
Types ¶
type App ¶
App holds build-time metadata for a CLI application. Create one in main() and call Run() to execute the root command.
func (*App) Run ¶
Run registers common persistent flags on cmd, then executes the command via fang.Execute with the formatted version string and signal handling.
func (*App) VersionString ¶
VersionString returns a formatted version string including commit, date, and builder info. Example: "1.2.3 (Commit: abc) (Date: 2026-01-01) (Built by: ci)"