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 ¶
- Variables
- func Main(args []string, in io.Reader, out, errOut io.Writer) int
- func Mistake(format string, args ...any) error
- func Pages() map[string]string
- func Program(name string, commands []Command, args []string, in io.Reader, ...) int
- func Run(ctx context.Context, args []string, in io.Reader, out, errOut io.Writer) int
- type Checked
- type Command
- type Env
- func (e *Env) Address() string
- func (e *Env) Client() (*client.Client, error)
- func (e *Env) Config() (identity.Config, error)
- func (e *Env) Context() context.Context
- func (e *Env) Controller() (*identity.Identity, store.Store, error)
- func (e *Env) Given(name string) bool
- func (e *Env) Open(recorded string, as *identity.Identity, ctl identity.Card) (store.Store, error)
- func (e *Env) Parse(args []string) ([]string, error)
- func (e *Env) Print(v any, text func() string) error
- func (e *Env) Say(format string, args ...any)
- type Leg
Constants ¶
This section is empty.
Variables ¶
var Commands []Command
Commands is the one table of commands.
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 ¶
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
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 mcp beside its own commands: its manual has its commands' pages among Corbie's, and a model is told the manual's page named after it when it connects.
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.
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
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
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
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) Controller ¶ added in v0.4.0
Controller gives the controller of this config and its store.
func (*Env) Given ¶ added in v0.4.0
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
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
Parse reads a command's flags, which may be written anywhere among its arguments, and gives the arguments that are not flags.