command

package
v0.194.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0, MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func Name(cmd Cmd) string

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

func RequiresArg(cmd Cmd) bool

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.

func Usage added in v0.102.3

func Usage(cmd Cmd) string

Usage returns the canonical invocation for cmd, shown when an argument is missing. It is empty for commands that take no argument.

Types

type Cmd

type Cmd int

Cmd is a recognized colon command.

const (
	CmdNone Cmd = iota
	CmdQuit
	CmdClear
	CmdHelp
	CmdCompact
	CmdStop
	CmdSteer
	CmdFollowUp
	CmdVerbose
	CmdSearch
	CmdTop
	CmdBottom
	CmdBanner
	CmdReloadRoles
	CmdLogin
	CmdLogout
	CmdSession
	CmdMCP
	CmdModel
	CmdAgent
	CmdMode
)

func Parse

func Parse(input string) Cmd

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.

func Split added in v0.102.3

func Split(input string) (Cmd, string)

Split parses a colon command string (without the leading ":") into its command and argument.

The argument is empty for commands that take none, and also when a required argument was omitted; RequiresArg tells those two cases apart. Unrecognized input yields CmdNone.

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.

type Entry

type Entry struct {
	Label string
	Desc  string
	Cmd   Cmd
}

Entry is a labelled command with description shown in the palette.

func DefaultEntries

func DefaultEntries() []Entry

DefaultEntries returns the standard command palette entries.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL