Documentation
¶
Overview ¶
Package commands owns command-catalog algorithms that are independent of Bubble Tea, plugin execution, and the CLI model.
Index ¶
- Constants
- func AppendHistory(entry string)
- func ApplySuggestion(input string, aliases map[string]string) string
- func BuiltInAliases() map[string]string
- func BuiltInCategories() map[string]string
- func BuiltInDescriptions() map[string]string
- func BuiltInNames() []string
- func Category(name string) string
- func HistoryPath() string
- func LoadHistory() []string
- func SaveHistory(history []string)
- func SuggestTypo(typo string, commandNames []string) string
- func Suggestions(input string, commandNames []string, descriptions, aliases map[string]string) []string
- func ValidateBuiltIns() error
- type ParsedInput
- type Registry
- type Resolution
- type Spec
Constants ¶
const MaxHistoryEntries = 1000
MaxHistoryEntries bounds persisted interactive input history.
Variables ¶
This section is empty.
Functions ¶
func AppendHistory ¶
func AppendHistory(entry string)
AppendHistory adds one non-empty entry to persistent history.
func ApplySuggestion ¶
ApplySuggestion turns a selected display value into a command input.
func BuiltInAliases ¶
BuiltInAliases returns aliases for built-in commands.
func BuiltInCategories ¶
BuiltInCategories returns the presentation category for built-in commands. Unknown commands intentionally fall back to Other so plugin commands remain usable without requiring a change to rho's catalog.
func BuiltInDescriptions ¶
BuiltInDescriptions returns the help text for built-in commands.
func BuiltInNames ¶
func BuiltInNames() []string
BuiltInNames returns the command names that are always available in rho. Dynamic plugin and subcommand names are supplied by the composition root.
func LoadHistory ¶
func LoadHistory() []string
LoadHistory loads history, returning an empty slice when no file exists.
func SaveHistory ¶
func SaveHistory(history []string)
SaveHistory deduplicates entries, keeps the last occurrence, and persists at most MaxHistoryEntries entries in chronological order.
func SuggestTypo ¶
SuggestTypo returns the closest known command when the edit distance is a plausible typo rather than a different word.
func Suggestions ¶
func Suggestions(input string, commandNames []string, descriptions, aliases map[string]string) []string
Suggestions returns matching command names with descriptions and aliases.
func ValidateBuiltIns ¶
func ValidateBuiltIns() error
ValidateBuiltIns checks the command metadata that powers completion and help. Keeping this invariant in the feature package prevents the CLI from advertising commands without descriptions or aliases pointing at commands that do not exist.
Types ¶
type ParsedInput ¶
ParsedInput is the normalized command input consumed by a CLI dispatcher.
func Parse ¶
func Parse(text string) ParsedInput
Parse normalizes the supported help shorthand and tokenizes command input. It deliberately does not resolve aliases or execute commands.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry owns canonical names, aliases, collision policy, and deterministic enumeration. Frontends attach their own typed handlers to these specs.
func NewRegistry ¶
func NewRegistry() *Registry
type Resolution ¶
type Resolution struct {
Parsed ParsedInput
Command string
Name string
IsSlash bool
Namespaced bool
}
Resolution is the pure routing decision made before a live command handler is consulted. Handler lookup remains a composition-root concern.
func Resolve ¶
func Resolve(parsed ParsedInput, aliases map[string]string) Resolution
Resolve applies aliases and derives the canonical registry key without executing or looking up a command.