Help us shape the future of Go! Take the 2026 Go Developer Survey

cli

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: AGPL-3.0 Imports: 67 Imported by: 0

Documentation

Overview

Package cli is the GoRun command line. cmd/gorun is a thin wrapper around Main; a downstream binary can call Main with Options to add modules and commands while keeping every core command and flag unchanged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(opts ...Option)

Configure resets the CLI to the core build, then applies opts. Main calls it; tests and downstream binaries may call it before Run or Modules. Process-wide registries (boot order, log categories, policy directory) are idempotent and are not reset.

func CoreModules

func CoreModules() []kernel.Module

CoreModules returns the core domain modules in boot order (see kernel.BootOrder). Only the orchestrator edits this list.

func InsertAfter

func InsertAfter(mods []kernel.Module, after string, extra ...kernel.Module) []kernel.Module

InsertAfter returns a copy of mods with extra inserted right after the module named after (appended when after is not present).

func Main

func Main(args []string, opts ...Option) int

Main runs the command line with args (without the program name) and returns the process exit code. Options are applied first (see Configure).

func Modules

func Modules(configs ...config.Config) []kernel.Module

Modules returns the modules every command boots: CoreModules, passed through the ModulesFunc options (WithModules) in order. The optional config is the loaded site config; without one the hooks get a zero Config.

func Run

func Run(args []string, in io.Reader, out io.Writer) error

Run dispatches one command with the options applied by Configure, reading stdin from in and writing command output to out.

Types

type Command

type Command struct {
	Name  string
	Usage string
	Run   func(args []string, in io.Reader, out io.Writer) error
}

Command is an extra top-level command. Usage is the exact help text for it (indented like the core lines, ending in a newline); commands are listed in registration order before api-docs. Run gets the arguments after Name.

type ModulesFunc

type ModulesFunc func(cfg config.Config, mods []kernel.Module) []kernel.Module

ModulesFunc receives the site config and the module list built so far (CoreModules first) and returns the list to boot. Use InsertAfter to keep a module at its BootOrder position.

type Option

type Option func(*settings)

Option configures the command line (see Configure).

func WithAddons

func WithAddons(names ...string) Option

WithAddons names the optional addons that "api-docs --addon NAME" accepts (each is booted with config Addons[NAME] = "enabled").

func WithBootOrder

func WithBootOrder(after string, names ...string) Option

WithBootOrder places extra module names in kernel.BootOrder right after the module named after, so Boot validates their position and Health lists them (see kernel.ExtendBootOrder).

func WithCommands

func WithCommands(cmds ...Command) Option

WithCommands adds top-level commands. A name that a core command already uses, or an earlier extra command, is ignored (core behavior never changes).

func WithLogCategory

func WithLogCategory(name, before string) Option

WithLogCategory adds an error-inventory category: error logs whose message starts with "name:" or "name " are filed under it (see diagnostics.RegisterCategory). before positions it in the list.

func WithModules

func WithModules(fn ModulesFunc) Option

WithModules adds a ModulesFunc. Funcs run in the order given.

func WithSitePolicyDirectory

func WithSitePolicyDirectory(dir string) Option

WithSitePolicyDirectory sets the root-owned directory the site module trusts for GORUN_SITE_POLICY files (see site.SetPolicyDirectory).

func WithVersion

func WithVersion(v string) Option

WithVersion sets the version printed by "gorun version" and reported as the API core version (api.CoreVersion).

Jump to

Keyboard shortcuts

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