Documentation
¶
Overview ¶
Package cli provides interactive CLI primitives for tools that need more than plain stdout but less than a full Bubble Tea TUI.
Index ¶
- func Confirm(prompt string, defaultYes bool) bool
- func Dim(msg string)
- func Error(msg string)
- func Errorf(format string, a ...any)
- func Info(msg string)
- func Infof(format string, a ...any)
- func Input(prompt string, validate func(string) error) (string, error)
- func KeyValue(key, value string)
- func MultiSelect(prompt string, items []string) ([]string, []int, error)
- func Password(prompt string, validate func(string) error) (string, error)
- func Section(msg string)
- func SelectOne(prompt string, items []string) (string, int, error)
- func Separator()
- func Step(current, total int, msg string)
- func Success(msg string)
- func Successf(format string, a ...any)
- func Title(msg string)
- func Warning(msg string)
- func Warningf(format string, a ...any)
- type Progress
- type SpinnerResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Confirm ¶
Confirm prints a yes/no prompt and returns the user's choice. Default value is used when the user presses Enter without typing. Shows Y/n if defaultYes is true, y/N otherwise.
func Input ¶
Input prompts for text input with optional validation. If validate is non-nil, the input is re-prompted on validation failure. Returns an error only if the user cancels with Ctrl+C.
func KeyValue ¶
func KeyValue(key, value string)
KeyValue prints a key-value pair with the key dimmed and value normal.
func MultiSelect ¶
MultiSelect presents a list of options with checkboxes and returns the selected items. Uses space/x to toggle, a to toggle all, arrow keys or j/k for navigation, Enter to confirm. Returns an error if the user cancels with Esc or Ctrl+C.
func Password ¶
Password prompts for masked text input with optional validation. Characters are displayed as bullet points (•). Returns an error only if the user cancels with Ctrl+C.
func SelectOne ¶
SelectOne presents a list of options and returns the selected item and its index. Uses arrow keys or j/k for navigation, Enter to confirm. Supports type-to-filter when there are more than 10 items. Returns an error if the user cancels with Esc or Ctrl+C.
func Step ¶
Step prints a numbered step indicator. Useful for multi-step CLI flows. Example: Step(1, 3, "Installing dependencies") → " 1/3 Installing dependencies"
Types ¶
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress shows a progress bar that updates as work completes.
func NewProgress ¶
NewProgress creates a progress bar with the given total and label.
type SpinnerResult ¶
type SpinnerResult struct {
// Stop halts the spinner and clears the line.
Stop func()
}
SpinnerResult is returned by Spin to stop the animation.
func Spin ¶
func Spin(message string) *SpinnerResult
Spin shows an animated spinner with a message. Call Stop() on the returned SpinnerResult when done. The spinner runs in a background goroutine and clears the line on stop.