cli

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package cli is the gskill command-line view. It parses commands with Kong, renders human or JSON output through a shared harness, and translates errors into process exit codes. It depends only on the app service layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DocsModel

func DocsModel() (*kong.Application, error)

DocsModel builds the Kong model for the gskill grammar without parsing arguments or exiting. It mirrors the parser constructed in Run, so generated reference documentation always reflects the real command surface. It exists solely for the reference generator (cmd/gen-reference) and changes nothing about the shipped CLI behavior.

func ListJSON

func ListJSON(skills []app.ListedSkill) map[string]any

ListJSON builds the stable --json object for a list result.

func Run

func Run(ctx context.Context, args []string, stdout, stderr io.Writer, application *app.App) int

Run parses args and executes the selected command, writing to stdout/stderr, and returns the process exit code. Usage errors map to code 2; any error a command returns is mapped through errs.ExitCode.

Types

type Globals

type Globals struct {
	Offline bool
	NoCache bool
	DryRun  bool
	Yes     bool
}

Globals carries the persistent flag values that commands consume.

type Output

type Output struct {
	// contains filtered or unexported fields
}

Output renders primary results to stdout and diagnostics to stderr, keeping the two channels separate so --json stdout stays machine-parseable (FR-035, FR-036).

func NewOutput

func NewOutput(stdout, stderr io.Writer, opts OutputOptions) *Output

NewOutput builds an Output. Interactive is forced off when stdout is not a TTY, so non-interactive (CI-safe) behavior is the default outside a terminal.

func (*Output) Diag

func (o *Output) Diag(format string, args ...any)

Diag writes a diagnostic line to stderr unless quiet is set.

func (*Output) Interactive

func (o *Output) Interactive() bool

Interactive reports whether interactive UI (prompts, colors) is enabled.

func (*Output) JSON

func (o *Output) JSON() bool

JSON reports whether JSON output is enabled.

func (*Output) Result

func (o *Output) Result(human string, v any) error

Result writes the primary command result to stdout. In JSON mode it encodes v as a single indented top-level object; otherwise it writes human.

type OutputOptions

type OutputOptions struct {
	JSON        bool
	Quiet       bool
	Interactive bool
}

OutputOptions configures an Output harness.

Jump to

Keyboard shortcuts

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