Documentation
¶
Overview ¶
Package command implements the colon command parser and command palette for the TUI.
Pressing Ctrl+P shows a list-based command palette. Commands mirror the REPL slash commands with additional TUI-specific commands.
Index ¶
Constants ¶
const PageName = "cmdlist_modal"
PageName is the tview Pages name used for the command list modal.
Variables ¶
This section is empty.
Functions ¶
func Name ¶ added in v0.102.3
Name returns the canonical name of cmd — the first entry in the command table, so aliases print as their primary spelling. It is empty for CmdNone.
func RequiresArg ¶ added in v0.102.3
RequiresArg reports whether cmd is useless without an argument.
func ShowList ¶
func ShowList(app *tview.Application, pages *tview.Pages, entries []Entry, onSelect func(Cmd), onDismiss func())
ShowList displays the command palette as a list-based modal. onSelect is called with the chosen command when an entry is selected. onDismiss is called when the modal is dismissed with Escape.
Types ¶
type Cmd ¶
type Cmd int
Cmd is a recognized colon command.
func Parse ¶
Parse maps a colon command string (without the leading ":") to a Cmd.
A bare command name parses too: Parse("steer") is CmdSteer with no argument, so callers can report a missing argument instead of an unknown command.
type Completion ¶ added in v0.102.3
type Completion struct {
Label string // command name, without the leading ':'
Desc string // one-line description shown beside the name
Insert string // text to place in the composer, e.g. ":steer "
}
Completion is one typeahead suggestion for the composer.
func Complete ¶ added in v0.102.3
func Complete(text string, entries []Entry) []Completion
Complete returns typeahead suggestions for text typed in the composer.
Suggestions are offered only while a command *name* is being typed: text that does not start with ':' — or that already contains a space, meaning an argument is in progress — yields none.