Documentation
¶
Overview ¶
Package cli provides CLI utilities for output formatting and user interaction.
Index ¶
- Constants
- func AddMutationFlags(cmd *cobra.Command, flags *MutationFlags)
- func AddOutputFlags(cmd *cobra.Command, flags *OutputFlags)
- func Error(format string, args ...any)
- func ExitCode(err error) int
- func ExitWith(code int, err error) error
- func Failure(format string, args ...any) error
- func Note(format string, args ...any)
- func Render(w io.Writer, data interface{}, flags OutputFlags) error
- func RenderMutation(w io.Writer, data interface{}, flags MutationFlags) error
- func RenderMutationTo(data interface{}, flags MutationFlags) error
- func RenderTo(data interface{}, flags OutputFlags) error
- func Success(format string, args ...any)
- func Warn(format string, args ...any)
- type MutationFlags
- type OutputFlags
Constants ¶
const ( ExitOK = 0 // Success ExitError = 1 // Generic error ExitUsage = 64 // Bad CLI syntax ExitDataErr = 65 // Invalid manifest/config ExitNoInput = 66 // File not found ExitSoftware = 70 // Internal error (bug) ExitCantCreate = 73 // Can't create file/symlink ExitIOErr = 74 // Read/write failure ExitNoPerm = 77 // Permission denied )
Exit codes following BSD sysexits.h conventions.
const DefaultFormat = "json"
DefaultFormat is the default output format (JSON for scriptability).
Variables ¶
This section is empty.
Functions ¶
func AddMutationFlags ¶
func AddMutationFlags(cmd *cobra.Command, flags *MutationFlags)
AddMutationFlags adds --passthru and --format flags for mutating commands.
func AddOutputFlags ¶
func AddOutputFlags(cmd *cobra.Command, flags *OutputFlags)
AddOutputFlags adds --filter and --format flags to a command.
func Failure ¶
Failure prints an error message via the shared cli facade and returns the wrapped error.
func Render ¶
func Render(w io.Writer, data interface{}, flags OutputFlags) error
Render outputs data according to the format specification.
func RenderMutation ¶
func RenderMutation(w io.Writer, data interface{}, flags MutationFlags) error
RenderMutation outputs data only if --passthru is set.
func RenderMutationTo ¶
func RenderMutationTo(data interface{}, flags MutationFlags) error
RenderMutationTo is a convenience function that renders to stdout if --passthru is set.
func RenderTo ¶
func RenderTo(data interface{}, flags OutputFlags) error
RenderTo is a convenience function that renders to stdout.
Types ¶
type MutationFlags ¶
MutationFlags holds flags for mutating commands (--passthru).
type OutputFlags ¶
OutputFlags holds the --filter and --format flag values.