Documentation
¶
Overview ¶
Package cli provides Sidecar's non-interactive command dispatch boundary.
Index ¶
- Constants
- func RemainingArgs(args []string) []string
- func RenderAgents(root *Command) string
- func RenderHelp(cmd *Command) string
- func RenderJSON(w io.Writer, cmd *Command) error
- func RenderMarkdownDoc(root *Command) string
- func Run(args []string, stdout, stderr io.Writer) (handled bool, exitCode int)
- func StartupConfigPage() (string, bool)
- type AgentDoc
- type ArgSpec
- type Command
- type Env
- type Example
- type ExitCode
- type Flag
- type TargetDoc
Constants ¶
const ConfigPageSetup = "setup"
ConfigPageSetup is the Configuration destination `sidecar setup` asks for. The app treats an unknown name as "the default page", which is what keeps the plumbing usable by a future caller that names a different one.
Variables ¶
This section is empty.
Functions ¶
func RemainingArgs ¶ added in v1.0.0
RemainingArgs is what the process should parse as flags after Run returns handled=false. A launch command consumes its own name, so `sidecar setup -project /x` parses -project exactly as `sidecar -project /x` does.
func RenderAgents ¶ added in v1.0.0
RenderAgents lists what an agent can do from Sidecar. It is generated from the same registry the help and the reference doc come from, so a command that grows an agent-facing use appears here by declaring it, not by someone remembering to update a list.
func RenderHelp ¶ added in v1.0.0
RenderHelp returns the formatted help string for a command.
func RenderJSON ¶ added in v1.0.0
RenderJSON writes the JSON representation of a command tree to w.
func RenderMarkdownDoc ¶ added in v1.0.0
RenderMarkdownDoc generates reference markdown documentation for the CLI command tree.
func Run ¶
Run dispatches a non-interactive command. handled=false leaves legacy TUI flag parsing entirely untouched.
func StartupConfigPage ¶ added in v1.0.0
StartupConfigPage reports the Configuration destination a launch command recorded, if any. main passes it to the app; nothing else reads it.
Types ¶
type AgentDoc ¶ added in v1.0.0
type AgentDoc struct {
Invocation string `json:"invocation,omitempty"`
Summary string `json:"summary,omitempty"`
}
AgentDoc is a command's agent-facing summary: an invocation and why it helps.
type ArgSpec ¶ added in v1.0.0
type ArgSpec struct {
Min int `json:"min"`
Max int `json:"max"` // -1 for unbounded
Description string `json:"description,omitempty"`
}
ArgSpec specifies positional argument requirements.
type Command ¶ added in v1.0.0
type Command struct {
Name string `json:"name"`
Summary string `json:"summary"`
Usage string `json:"usage"`
Long string `json:"long,omitempty"`
Targets []TargetDoc `json:"targets,omitempty"`
Flags []Flag `json:"flags,omitempty"`
Args ArgSpec `json:"args,omitempty"`
ExitCodes []ExitCode `json:"exitCodes,omitempty"`
Examples []Example `json:"examples,omitempty"`
Sub []*Command `json:"subcommands,omitempty"`
Run func(Env, []string) int `json:"-"`
// Launch is for a command that does not run non-interactively at all: it
// records what the app should do and hands the process back to normal
// startup by reporting handled=false. `sidecar setup` is the only one — it
// starts Sidecar the ordinary way with Configuration open, rather than
// printing a second settings interface into the terminal.
Launch func(Env, []string) (handled bool, exitCode int) `json:"-"`
// Agent is what `sidecar --agents` says about this command: the one line an
// agent needs to decide whether to reach for it. Commands without one are
// left out of that list, so it stays a short list of things worth doing
// rather than a second copy of the help.
Agent AgentDoc `json:"agent,omitempty"`
}
Command is a declarative command definition.
func RootCommand ¶ added in v1.0.0
func RootCommand() *Command
RootCommand returns the root command hierarchy.
func (*Command) FindSubcommand ¶ added in v1.0.0
FindSubcommand looks up a direct child subcommand by name.
type Example ¶ added in v1.0.0
type Example struct {
Description string `json:"description,omitempty"`
Command string `json:"command"`
}
Example illustrates command usage.