cli

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 38 Imported by: 0

Documentation

Overview

Package cli wires the command-line surface: Runefile resolution, the parse → analyze → run pipeline, task dispatch, and exit-code mapping.

Index

Constants

View Source
const (
	ExitSuccess    = 0   // all requested tasks succeeded
	ExitTaskFail   = 1   // a task body failed
	ExitUsage      = 2   // usage error / no Runefile / unknown task / bad args
	ExitValidation = 3   // static parse/analyze error — nothing executed
	ExitInterrupt  = 130 // interrupted (SIGINT)
)

Exit codes (contracts/cli.md, FR-021).

Variables

This section is empty.

Functions

func CodeFor

func CodeFor(err error) int

CodeFor maps an error returned by Run to a process exit code.

func Run

func Run(opts Options, args []string) error

Run executes one CLI invocation. args is everything after the global flags: VAR=VALUE overrides interleaved with task names and their arguments.

The full pipeline (lex → parse → analyze → schedule → execute) is wired in run.go; this function resolves the Runefile and delegates.

func ServeMCP

func ServeMCP(opts Options, useHTTP bool, addr, tokenFile string) error

ServeMCP starts the MCP server over stdio (default) or Streamable HTTP.

Types

type Interrupted

type Interrupted struct{ Err error }

Interrupted marks a SIGINT (exit 130).

func (*Interrupted) Error

func (e *Interrupted) Error() string

func (*Interrupted) Unwrap

func (e *Interrupted) Unwrap() error

type Options

type Options struct {
	File       string // -f/--file
	List       bool   // --list
	DryRun     bool   // --dry-run
	Summary    bool   // --summary
	Dump       bool   // --dump
	DumpFormat string // --format (with --dump)
	Set        []string
	Watch      bool
	Choose     bool
	Yes        bool
	Quiet      bool
	Fmt        bool
	ClearCache bool

	// Resolved per-stream color decisions (see cmd/rune): ColorStdout gates
	// --list and --help (which write to stdout); ColorStderr gates Rune's own
	// messages — status/echo/cache lines and diagnostics — on stderr.
	ColorStdout bool
	ColorStderr bool
	Version     string
	Cwd         string
	Ctx         context.Context // cancelled on SIGINT (nil => Background)
	Stdin       io.Reader
	Stdout      io.Writer
	Stderr      io.Writer

	// Commands are the reserved subcommand names (and aliases). They are used
	// only to enrich the "unknown task" error with a did-you-mean suggestion.
	Commands []string
}

Options carries the resolved global CLI flags and I/O streams for one invocation. main.go populates it from cobra and passes it to Run.

type TaskCandidate

type TaskCandidate struct {
	Name string
	Doc  string
}

TaskCandidate is a completable task: its name plus the first line of its doc comment, used as the shell-completion description.

func TaskCandidates

func TaskCandidates(opts Options) []TaskCandidate

TaskCandidates returns the non-private, OS-matching tasks of the resolved Runefile, each with its first doc line, for dynamic shell completion. It is deliberately tolerant: any failure (no Runefile, read error, parse/compose error) yields nil so completion degrades gracefully and never disrupts the shell session. The analyzer is intentionally skipped — task names should still complete when the Runefile has semantic (not syntactic) errors.

type TaskFailure

type TaskFailure struct {
	Err    error
	Silent bool
}

TaskFailure marks a task body failure (exit 1). Silent suppresses the trailing error banner (the [no-exit-message] attribute) without changing the exit code.

func (*TaskFailure) Error

func (e *TaskFailure) Error() string

func (*TaskFailure) Unwrap

func (e *TaskFailure) Unwrap() error

type UsageError

type UsageError struct{ Err error }

UsageError marks an error as a usage/discovery problem (exit 2).

func (*UsageError) Error

func (e *UsageError) Error() string

func (*UsageError) Unwrap

func (e *UsageError) Unwrap() error

type ValidationError

type ValidationError struct{ Err error }

ValidationError marks a static parse/analyze failure (exit 3). The diagnostics have already been rendered to stderr by the caller; this type only carries the exit code intent.

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Jump to

Keyboard shortcuts

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