Documentation
¶
Overview ¶
Package cli is the tailkeeper command line (spec §16). Tool commands come from the registry: `tailkeeper <area> <verb>` runs the tool with that area and verb, and its flags come from the tool's input type, so the CLI and MCP accept the same parameters and share validation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Runner ¶
type Runner struct {
Stdout, Stderr io.Writer
// Build loads configuration for the named context (app.Build in production).
Build func(ctx context.Context, contextName string) (*app.App, error)
// Reexec replaces the process with the exec provider's wrapper; it returns only on failure.
Reexec func(p config.Provider) error
// ServeMCP serves srv until the client goes away (stdio in production).
ServeMCP func(ctx context.Context, srv *mcp.Server) error
Now func() time.Time
// Stdin is standard input, read by a flag such as --from - in the process that
// holds the credential; nil reads as empty.
Stdin io.Reader
// Registry returns the tools the commands run; nil means the product's. Tests
// set it to run the framework through tools of their own.
Registry func() *registry.Registry
// Probe runs `probe-acl`, the owner's live probes of the validate endpoint. It
// is nil in every build but one made with -tags probe, which only `make probe-acl` makes;
// with it nil the command does not exist: it is not in the help and answers as an unknown
// area.
Probe func(ctx context.Context, c *api.Client, args []string, stdout, stderr io.Writer) int
// Getenv reads the environment (os.Getenv when nil): TAILKEEPER_LIVE for probe-acl, and
// NO_COLOR and TERM for the colour of the human layout. IsTerminal says whether a writer
// is a terminal (a character device when nil).
Getenv func(string) string
IsTerminal func(io.Writer) bool
}
Runner runs one command line. Its dependencies are injected for tests.
func (*Runner) Run ¶
Run executes args (without the program name) and returns the exit code.
Everything the command line prints to standard output and standard error goes through guardLine, line by line, here, so that no writer of a command can forget it: usage text, warnings, the lines of audit and doctor, and the text of errors. The JSON a command prints is escaped by writeJSON and writeJSONLine, which leave a line the guard has nothing to change. The mcp command does not write to standard output through the Runner: its stdout is the protocol's, and ServeMCP owns it.