cli

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 34 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli implements the workloom command surface: global switches, command dispatch, output rendering and the exit-code taxonomy. Keeping dispatch out of main() makes the exit contract testable.

Since M4.2 every business operation lives in the shared application service (internal/app); this package only parses flags, calls the service and renders. The MCP server (internal/mcp) calls the same service, so no entry point can bypass a constraint the others enforce.

Index

Constants

View Source
const (
	CodeOK           = 0
	CodeInternal     = 1
	CodeUsage        = 2
	CodePrecondition = 3
	// CodeInvalid reports managed state that exists but cannot be trusted:
	// parse errors, unknown keys, wrong types, unsupported schema_version.
	// Write commands refuse; read-only diagnostics keep working (方案 §14.1).
	CodeInvalid = 4
	// CodeStale and CodeMissing are the knowledge layer's own codes
	// (方案 §12.5): a stale page layer, and a page layer that does not exist.
	CodeStale   = 10
	CodeMissing = 11
)

Exit codes, pinned by tests so scripts may rely on them:

0  success
1  internal error
2  usage error
3  precondition error
4  invalid managed state

`knowledge status` (and a refresh that found nothing to regenerate) adds a second, reserved convention on top: 10 = the page layer is stale, 11 = the page layer has not been generated (方案 §12.5). Those commands answer with that state through stdout and then exit with the matching code; no other command uses 10 or 11.

Variables

This section is empty.

Functions

func Run

func Run(args []string, stdout, stderr io.Writer) int

Run executes one CLI invocation against the process streams and returns the process exit code.

func RunWithIO

func RunWithIO(args []string, stdin io.Reader, stdout, stderr io.Writer) int

RunWithIO is Run with an explicit stdin, so `mcp serve` — and its tests — can drive the stdio protocol over injected streams.

Types

This section is empty.

Jump to

Keyboard shortcuts

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