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 ¶
- func Configure(opts ...Option)
- func CoreModules() []kernel.Module
- func InsertAfter(mods []kernel.Module, after string, extra ...kernel.Module) []kernel.Module
- func Main(args []string, opts ...Option) int
- func Modules(configs ...config.Config) []kernel.Module
- func Run(args []string, in io.Reader, out io.Writer) error
- type Command
- type ModulesFunc
- type Option
- func WithAddons(names ...string) Option
- func WithBootOrder(after string, names ...string) Option
- func WithCommands(cmds ...Command) Option
- func WithLogCategory(name, before string) Option
- func WithModules(fn ModulesFunc) Option
- func WithSitePolicyDirectory(dir string) Option
- func WithVersion(v string) Option
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 ¶
CoreModules returns the core domain modules in boot order (see kernel.BootOrder). Only the orchestrator edits this list.
func InsertAfter ¶
InsertAfter returns a copy of mods with extra inserted right after the module named after (appended when after is not present).
func Main ¶
Main runs the command line with args (without the program name) and returns the process exit code. Options are applied first (see Configure).
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 ¶
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 ¶
WithAddons names the optional addons that "api-docs --addon NAME" accepts (each is booted with config Addons[NAME] = "enabled").
func WithBootOrder ¶
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 ¶
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 ¶
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 ¶
WithSitePolicyDirectory sets the root-owned directory the site module trusts for GORUN_SITE_POLICY files (see site.SetPolicyDirectory).
func WithVersion ¶
WithVersion sets the version printed by "gorun version" and reported as the API core version (api.CoreVersion).