cli

package
v0.1.0-dev.20260819154703 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package cli provides CLI utilities for output formatting and user interaction.

Index

Constants

View Source
const (
	ExitOK          = 0  // Success
	ExitError       = 1  // Generic error
	ExitUsage       = 64 // Bad CLI syntax
	ExitDataErr     = 65 // Invalid manifest/config
	ExitNoInput     = 66 // File not found
	ExitUnavailable = 69 // Registry unreachable
	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.

View Source
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 Error

func Error(format string, args ...any)

Error prints an error message via the shared cli facade.

func ExitCode

func ExitCode(err error) int

ExitCode extracts the exit code from an error.

func ExitWith

func ExitWith(code int, err error) error

ExitWith returns an error that carries a specific exit code.

func Failure

func Failure(format string, args ...any) error

Failure prints an error message via the shared cli facade and returns the wrapped error.

func Note

func Note(format string, args ...any)

Note prints an informational message via the shared cli facade.

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.

func Success

func Success(format string, args ...any)

Success prints a success message via the shared cli facade.

func Warn

func Warn(format string, args ...any)

Warn prints a warning message via the shared cli facade.

Types

type MutationFlags

type MutationFlags struct {
	Passthru bool
	Format   string
}

MutationFlags holds flags for mutating commands (--passthru).

type OutputFlags

type OutputFlags struct {
	Format string
	Filter []string
}

OutputFlags holds the --filter and --format flag values.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL