Documentation
¶
Overview ¶
Package menu defines the descriptors the TUI uses to render a generic, navigable menu stack. Every client package builds its install/launch flow by returning nested Menu values from its action closures; the TUI takes care of cursor movement, digit shortcuts, Esc-to-pop, and dispatching tea.Cmds.
Index ¶
Constants ¶
const DigitZero = -10
DigitZero pins a MenuItem to the numeric shortcut "0". It is a distinct sentinel because zero is the natural zero value for the Digit field, which has "use default" semantics.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecDoneMsg ¶
type ExecDoneMsg struct{ Err error }
ExecDoneMsg is emitted when a foreground client process exits (launched via tea.ExecProcess from inside a client's Action). The TUI's menu engine handles this by clearing the stack and re-running preflight.
type InstallDoneMsg ¶
type InstallDoneMsg struct{ Err error }
InstallDoneMsg is emitted when an install command finishes. The TUI's menu engine handles this by rebuilding the root menu (re-scanning which clients are installed).
type LaunchDoneMsg ¶
type LaunchDoneMsg struct{ Err error }
LaunchDoneMsg is emitted when a GUI launch (desktop app) returns control immediately. Unlike ExecDoneMsg, the TUI does not re-run preflight — launching a desktop app does not invalidate anything.
type Menu ¶
type Menu struct {
Title string
Items []MenuItem
Hint string
// OnBack, when non-nil, overrides the default "pop stack one level"
// behavior on Esc. Returning a nil tea.Cmd simply stays on this menu.
OnBack func() tea.Cmd
}
Menu is a list of selectable items plus optional title and footer hint.
type MenuItem ¶
type MenuItem struct {
Label string
Description string
Kind Kind
Disabled bool
// Hidden items are skipped by the renderer but kept in the slice so
// numeric shortcuts remain stable.
Hidden bool
// Digit, when set to a non-negative value, renders as the leading "[N]"
// prefix and makes the item selectable via that keystroke. A zero
// value means "use the default": the item's 1-based position in the
// menu's Items slice. Set Digit to DigitZero to pin the item to [0].
Digit int
// Shortcut is an alternative single-character key that activates this
// item (e.g. "s" for Settings, "a" for Add endpoint). Empty disables.
Shortcut string
// Action runs when the item is selected.
Action func() Result
}
MenuItem is one selectable row in a Menu.
type Result ¶
type Result struct {
// Next pushes a submenu onto the stack.
Next *Menu
// Replace swaps the top of the stack in place.
Replace *Menu
// Cmd dispatches a tea.Cmd. The engine pops the stack when the command's
// done-msg arrives (typically via ExecProcess). Use PopOnDone=false to
// suppress that.
Cmd tea.Cmd
PopOnDone bool
// Pop goes back one level.
Pop bool
// Quit terminates the program.
Quit bool
}
Result is what an Action returns. Exactly one field is populated.
type SimpleDoneMsg ¶
type SimpleDoneMsg struct{ Err error }
SimpleDoneMsg is a generic "a tea.Cmd finished" marker that the engine uses to pop the stack one level. Suitable for uninstall-style actions that complete synchronously without touching the agent binary layout.