Documentation
¶
Overview ¶
Package clicmd is the server-side registry for CLI subcommands forwarded over the admin API — the "zero-install plugin" path. When `txco <name> ...` is not a built-in (and no local txco-<name> plugin handles it), the CLI POSTs the argv to /v1/cli and the server runs the registered handler for <name>, returning its rendered output + exit code.
The seam is generic and billing-neutral: an overlay self-registers a command from its init() and the product binary activates it with a blank import — the same compile-time pattern as usage.Register / bgservice.Register. Open core registers no commands, so an unknown command 404s and the CLI gracefully falls back to its unknown-subcommand error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cursor ¶ added in v0.2.10
Cursor returns the poll cursor for this invocation — empty on the first poll or for a non-pollable command. A handler echoes a new cursor via Result.Cursor to be passed back on the next poll.
Types ¶
type Handler ¶
Handler runs one forwarded command server-side. args is everything after the command name — for `txco credit grant add acme 5`, name is "credit" and args is ["grant","add","acme","5"]. The endpoint has already enforced super-admin. A returned error is an INTERNAL failure (rendered as HTTP 500); user-facing errors (bad args, not found) should be a Result with a non-zero Exit + Stderr, nil error — so they render like a normal CLI error, not a server fault.
type Result ¶
type Result struct {
Stdout string
Stderr string
Exit int
// Cursor + PollAfterMs make a forwarded command POLLABLE. When PollAfterMs
// > 0, the forwarding CLI prints Stdout/Stderr, waits that many ms, then
// re-invokes the SAME command passing Cursor back (read via Cursor(ctx)) —
// looping until the user interrupts or a result with PollAfterMs == 0
// arrives. This lets a command stream incrementally over repeated /v1/cli
// requests with no streaming transport. Zero values keep the classic
// single-shot behaviour, so existing commands are unaffected.
Cursor string
PollAfterMs int
}
Result is a forwarded command's rendered output plus a process-style exit code. The CLI prints Stdout/Stderr verbatim and exits with Exit.