cli

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 32 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. `agents` keeps its existing shape (plain agent-ID strings); `active`, `agent_health`, `commit`, and `content_hash` are additive fields carrying what `gskill status --json` used to report on its own (spec 013 FR-005, clarification Q2).

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) Confirm added in v0.2.0

func (o *Output) Confirm(prompt string, assumeYes bool) bool

Confirm prompts on stderr for a yes/no answer read from stdin, defaulting to No. It returns true without prompting when assumeYes is set or the session is non-interactive, so unattended and CI runs never block (FR-012).

func (*Output) Diag

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

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

func (*Output) ErrDiag added in v0.3.0

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

ErrDiag writes an error-severity diagnostic to stderr, red on an interactive terminal. Unlike a command's returned error (which Run maps to an exit code), this is for error-severity lines a command reports without failing the whole run — and for Run's own error-reporting lines.

func (*Output) Hint added in v0.3.0

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

Hint writes a dimmed, actionable follow-up line to stderr — the arrow-prefixed suggestion shown after an error (e.g. "→ run 'gskill doctor'").

func (*Output) Info added in v0.3.0

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

Info writes a neutral diagnostic to stderr, dimmed on an interactive terminal.

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.

func (*Output) Warn added in v0.3.0

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

Warn writes a warning-severity diagnostic to stderr, yellow on an interactive terminal.

type OutputOptions

type OutputOptions struct {
	JSON        bool
	Quiet       bool
	Interactive bool
	// Verbose enables the stable one-line-per-skill install progress on
	// non-interactive runs (spec 014 FR-022); wired from the global -v flag.
	Verbose bool
}

OutputOptions configures an Output harness.

Jump to

Keyboard shortcuts

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