cli

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 44 Imported by: 2 modules, 4 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 is Corbie's command line. Everything it does to a run it does through the client package, so one act gives one answer in one set of words however it is asked for.

Index

Constants

This section is empty.

Variables

View Source
var Commands []Command

Commands is the one table of commands.

View Source
var Version string

Version is which build of this binary this is: of Corbie, or of a program read with Program. A release build is given it; any other build reads it from the main module's build information.

Functions

func Main

func Main(args []string, in io.Reader, out, errOut io.Writer) int

Main runs the command line and gives its exit status: 0 for success, 2 for a mistake in how the command was written, 1 for failure.

func Mistake added in v0.4.0

func Mistake(format string, args ...any) error

Mistake is a mistake in how a command was written. The command ends with status 2, and its usage line is printed after what is wrong.

func Program added in v0.4.0

func Program(name string, commands []Command, args []string, in io.Reader, out, errOut io.Writer) int

Program runs the command line of a program that corbie <name> runs, from the program's own table of commands, and gives its exit status as Main does. A command named "" is the one run when no other is named. The program is given corbie's manual and version beside its own commands, and its manual has its commands' pages among Corbie's. corbie mcp reads that manual to give a model the program's commands, and tells the model the page named after the program.

func Run

func Run(ctx context.Context, args []string, in io.Reader, out, errOut io.Writer) int

Run is Main under a context.

Types

type Checked

type Checked struct {
	OK   bool  `json:"ok"`
	Legs []Leg `json:"legs"`
	// Run is the check's run, when it did not go as it should.
	Run *client.Run `json:"run,omitzero"`
}

A Checked is what a check found.

type Command

type Command struct {
	Name    string // as it is typed: "run submit", "controller enrol"
	Usage   string // what follows the name
	Summary string // one line
	Help    string // the rest of its page
	// Stays says the command stays until a run ends, or until stopped.
	Stays bool
	// Run carries the command out with what followed its name.
	Run func(e *Env, args []string) error
}

A Command is one command of the binary, or of a program that corbie <name> runs. The commands, their help, the manual's pages about them and the names by which a model is allowed to run them all come from the one table of these.

func Find

func Find(args []string) (*Command, []string)

Find gives the command a command line names, as the one reading of it.

type Env added in v0.4.0

type Env struct {
	In    io.Reader
	Out   io.Writer // the command's result
	Err   io.Writer // everything said along the way
	Flags *flag.FlagSet
	// contains filtered or unexported fields
}

An Env is what a command is run with: where it reads and writes, and the flags every command takes. The command adds its own to Flags.

func (*Env) Address added in v0.4.0

func (e *Env) Address() string

Address is the address of the store the command opened last, or "" when it has opened none.

func (*Env) Client added in v0.4.0

func (e *Env) Client() (*client.Client, error)

Client gives the client of this config: its identity, the controller it trusts and that controller's store. With no identity it is a viewer.

func (*Env) Config added in v0.4.0

func (e *Env) Config() (identity.Config, error)

Config is the config the command uses: the one --config or CORBIE_CONFIG names, or by default the one in the user's config directory.

func (*Env) Context added in v0.4.0

func (e *Env) Context() context.Context

Context is ended when the command is stopped.

func (*Env) Controller added in v0.4.0

func (e *Env) Controller() (*identity.Identity, store.Store, error)

Controller gives the controller of this config and its store.

func (*Env) Given added in v0.4.0

func (e *Env) Given(name string) bool

Given says whether a flag was written on the command line. A flag that would have no effect on what was asked for is refused as a mistake, so that nobody believes a limit is in force that is not.

func (*Env) Open added in v0.4.0

func (e *Env) Open(recorded string, as *identity.Identity, ctl identity.Card) (store.Store, error)

Open opens the store the command uses: the one --store names, or else the one CORBIE_STORE names, or else recorded. It refuses a store whose layout this Corbie does not know. A directory another computer serves is opened as a party: as is the party's identity, and ctl the card of the controller whose computer serves it.

func (*Env) Parse added in v0.4.0

func (e *Env) Parse(args []string) ([]string, error)

Parse reads a command's flags, which may be written anywhere among its arguments, and gives the arguments that are not flags.

func (*Env) Print added in v0.4.0

func (e *Env) Print(v any, text func() string) error

Print writes a command's result: as JSON if that was asked for, or as the text given.

func (*Env) Say added in v0.4.0

func (e *Env) Say(format string, args ...any)

Say writes a line of what the command says along the way.

type Leg

type Leg struct {
	Leg     string  `json:"leg"`
	Status  string  `json:"status"` // ok, late or never
	Seconds float64 `json:"seconds,omitzero"`
	Why     string  `json:"why,omitzero"`
}

A Leg is one thing the check's run needed, and what became of it.

Jump to

Keyboard shortcuts

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