Documentation
¶
Overview ¶
Package commands provides command tree navigation and execution for the star runtime.
Index ¶
- type CommandFlag
- type CommandInfo
- type CommandRef
- type CommandTree
- type Provider
- func (p *Provider) Children(parent string) ([]*CommandRef, error)
- func (p *Provider) Current() (string, error)
- func (p *Provider) Get(name string) (*CommandRef, error)
- func (p *Provider) Parent() (string, error)
- func (p *Provider) Query(pattern string) ([]*CommandRef, error)
- func (p *Provider) Run(name string, flags map[string]string) (RunResult, error)
- func (p *Provider) Siblings() ([]*CommandRef, error)
- type RunResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandFlag ¶
type CommandFlag struct {
Name string `starlark:"name"`
Help string `starlark:"help"`
Default string `starlark:"default"`
}
CommandFlag represents a command flag.
type CommandInfo ¶
type CommandInfo struct {
Name string `starlark:"name"`
Help string `starlark:"help"`
Flags []CommandFlag `starlark:"flags"`
}
CommandInfo describes a registered extension command.
type CommandRef ¶
type CommandRef struct {
// contains filtered or unexported fields
}
CommandRef wraps a command for use in Starlark. It implements starlark.Value and starlark.HasAttrs, exposing name, help, flags, and a callable run method.
func NewCommandRef ¶
func NewCommandRef(name string, tree CommandTree) *CommandRef
NewCommandRef creates a new CommandRef.
func (*CommandRef) Attr ¶
func (r *CommandRef) Attr(name string) (starlark.Value, error)
Attr implements starlark.HasAttrs.
func (*CommandRef) AttrNames ¶
func (r *CommandRef) AttrNames() []string
AttrNames implements starlark.HasAttrs.
func (*CommandRef) Hash ¶
func (r *CommandRef) Hash() (uint32, error)
Hash implements starlark.Value.
func (*CommandRef) Truth ¶
func (r *CommandRef) Truth() starlark.Bool
Truth implements starlark.Value.
type CommandTree ¶
type CommandTree interface {
// CommandNames returns all registered command names (space-separated).
CommandNames() []string
// RunCommand executes a command by space-separated name with the given flags
// and optional positional arguments.
RunCommand(name string, flags map[string]string, positional ...string) error
// CommandHelp returns the help text for a command.
CommandHelp(name string) string
// CommandFlags returns the flags for a command as (name, help, default) tuples.
CommandFlags(name string) []CommandFlag
}
CommandTree provides access to the command hierarchy. The Runtime implements this interface and injects it via context Data["command_tree"].
type Provider ¶
type Provider struct {
op.ProviderBase
}
Provider provides command tree navigation and execution operations.
+devlore:access=immediate
func NewProvider ¶
func NewProvider(ctx *op.RuntimeEnvironment) *Provider
NewProvider creates a commands provider bound to the given context. Declares interest in the "command_tree" variable so the resolver populates it from the [application.Application]'s source maps at construction time. The "current_command" handle is read per-dispatch from [op.RuntimeEnvironment.Application.Overrides] directly — it mutates as cobra dispatches each subcommand, which doesn't fit the construction-time resolution model.
func (*Provider) Children ¶
func (p *Provider) Children(parent string) ([]*CommandRef, error)
Children returns all child commands of the given parent path.
+devlore:defaults parent=""
Parameters:
- parent: parent path to search (default: current command's parent)
Returns:
- []*CommandRef: child commands
- error: never
func (*Provider) Current ¶
Current returns the name of the currently executing command.
Returns:
- string: the dot-separated command name
- error: never
func (*Provider) Get ¶
func (p *Provider) Get(name string) (*CommandRef, error)
Get returns a specific command by name, or nil if not found.
Parameters:
- name: dot-separated command name
Returns:
- *CommandRef: the command, or nil
- error: never
func (*Provider) Parent ¶
Parent returns the parent path of the current command.
Returns:
- string: the parent path (e.g., "lint" for "lint.all")
- error: never
func (*Provider) Query ¶
func (p *Provider) Query(pattern string) ([]*CommandRef, error)
Query returns commands matching a pattern with * wildcards.
Parameters:
- pattern: glob pattern (e.g., "lint.*", "*.go", "*")
Returns:
- []*CommandRef: matching commands
- error: never
func (*Provider) Run ¶
Run executes a command by name with the given arguments.
Parameters:
- name: dot-separated command name
- flags: keyword arguments passed to the command
Returns:
- RunResult: pass/fail and error message
- error: if command not found
func (*Provider) Siblings ¶
func (p *Provider) Siblings() ([]*CommandRef, error)
Siblings returns all sibling commands (same parent, excluding self).
Returns:
- []*CommandRef: sibling commands
- error: never