cli

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

Package cli wires the cobra command tree. Discoverability features:

  • auto --help on every (sub)command, with examples
  • did-you-mean suggestions for mistyped commands (cobra built-in)
  • global --output table|json with a stable error envelope
  • stable, documented exit codes (see `normatik explain exit-codes`)

Shared machinery (deps, handled errors, error-render, resource registry) lives in internal/command; this package only wires commands together.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LeafCommandPaths

func LeafCommandPaths() []string

LeafCommandPaths builds the real cobra command tree (the same tree Main() executes against — including cobra's built-in `help`/`completion`, added the same way Execute() adds them) and returns the full space-joined path of every LEAF command (a command with no children — the only nodes that ever make an API call or run their own logic; pure routing parents like `pages` or `users` are excluded). Hidden commands (cobra's own `__complete`/`__completeNoDesc` shell-completion protocol commands) are excluded too: they are not discoverable, agent-facing commands.

This exists so the e2e completeness guard (e2e's INFRA test) can diff the CLI's actual command surface against the READ_ONLY read/write matrices without parsing --help text (styled/rendered by fang, not a stable format) and without re-deriving the tree via source/AST scanning (most `Use:` strings are passed through builder helpers as parameters, not literals in a `cobra.Command{}` composite literal, so an AST walk over composite literals alone would silently miss most leaves).

func Main

func Main() int

Main builds and runs the root command and returns the process exit code. fang adds styled help, --version, completion and styled errors; we keep our own structured API-error rendering + exit-code mapping by passing a custom error handler that skips errors we already rendered ourselves.

Types

type LeafCommand

type LeafCommand struct {
	Path  string
	Write bool
}

LeafCommand is one visible leaf of the real command tree with its read/mutating classification (from the write annotation, inherited down the subtree it was registered under).

func LeafCommands

func LeafCommands() []LeafCommand

LeafCommands returns every visible leaf with its classification, sorted by path. Same tree semantics as documented above for LeafCommandPaths.

Jump to

Keyboard shortcuts

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