Documentation
¶
Overview ¶
Package bubbles owns the CLI's small reusable terminal-UI primitives.
The single-line SpinnerView in this file is intentionally NOT built on bubbletea. The bubbletea v2 renderer probes for terminal capabilities (DEC private modes 2026 "Synchronized Output" and 2027 "Unicode Core") the first time it starts. For long-running TUIs that's harmless — the terminal's reply arrives while bubbletea is still reading input. For short-lived spinners (e.g. `nuon orgs webhooks delete`), the program quits via tea.Quit a few hundred milliseconds later when the API call returns, well before the terminal flushes its reply. The reply then leaks to the user's shell and shows up at the next prompt as raw bytes like `^[[?2026;2$y^[[?2027;2$y`.
The fix is to keep the spinner off bubbletea entirely: render a single line directly to stdout with `\r` overwrites and ANSI clear-to-EOL. This matches the visual output of the previous spinner.Dot model, supports the same Start / Update / Success / Fail surface, and can never trigger a terminal-capability probe because we don't construct a tea.Program at all.
Index ¶
- Variables
- func ColoredText(text, color string) string
- func Confirm(prompt string, interactive bool) (bool, error)
- func ConfirmWithDefault(prompt string, defaultYes, interactive bool) (bool, error)
- func DetectUserJourney(orgName string, userData map[string]interface{}) string
- func EvaluationConfirm(prompt string, interactive bool) (bool, error)
- func Green(text string) string
- func InlineConfirm(prompt string, defaultYes, interactive bool) (bool, error)
- func ParseOrgSelection(selection string) (name, id string)
- func PromptText(prompt, placeholder, help string, required, interactive bool) (string, error)
- func PromptWithAutoApprove(autoApprove, interactive bool, msg string, vars ...interface{}) error
- func Red(text string) string
- func RenderMarkdownTable(headers []string, rows [][]string) string
- func RunOnboarding(userJourney string, interactive bool) error
- func RunSpinnerWithContext(ctx context.Context, message string, operation func(ctx context.Context) error, ...) error
- func SelectApp(apps []AppOption, interactive bool) (string, error)
- func SelectFromItems(title string, items []SelectorItem, interactive bool) (string, error)
- func SelectFromItemsWithMaxRows(title string, items []SelectorItem, maxVisibleRows int, interactive bool) (string, error)
- func SelectFromOptions(title string, options []string, interactive bool) (string, error)
- func SelectFromOptionsWithMaxRows(title string, options []string, maxVisibleRows int, interactive bool) (string, error)
- func SelectInstall(installs []InstallOption, interactive bool) (string, error)
- func SelectOrg(orgs []OrgOption, searchFn func(string) ([]OrgOption, error), interactive bool) (string, error)
- func SelectWorkflow(workflows []WorkflowOption, interactive bool) (string, error)
- func ShowConfirmDialog(message string, interactive bool) (bool, error)
- func ShowEvaluationWelcome()
- func Yellow(text string) string
- type AppOption
- type ConfirmDialogModel
- type ConfirmModel
- type FinalRenderMsg
- type InlineConfirmModel
- type InstallOption
- type MultiSpinnerModel
- func (m *MultiSpinnerModel) AddSpinner(id, message string)
- func (m MultiSpinnerModel) AllCompleted() bool
- func (m MultiSpinnerModel) HasErrors() bool
- func (m MultiSpinnerModel) Init() tea.Cmd
- func (m MultiSpinnerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m MultiSpinnerModel) View() tea.View
- type MultiSpinnerView
- func (v *MultiSpinnerView) AddSpinner(id, message string)
- func (v *MultiSpinnerView) AllCompleted() bool
- func (v *MultiSpinnerView) CompleteSpinner(id string, success bool, finalMsg string)
- func (v *MultiSpinnerView) HasErrors() bool
- func (v *MultiSpinnerView) Start()
- func (v *MultiSpinnerView) Stop()
- func (v *MultiSpinnerView) UpdateSpinner(id, message string)
- func (v *MultiSpinnerView) Wait()
- type OnboardingModel
- type OnboardingStep
- type OrgOption
- type RenderCompleteMsg
- type SelectorItem
- type SelectorModel
- type SpinnerCompleteMsg
- type SpinnerState
- type SpinnerUpdateMsg
- type SpinnerView
- type TableModel
- type TableView
- func (v *TableView) Print(msg string)
- func (v *TableView) Render(data [][]string)
- func (v *TableView) RenderInteractive(data [][]string, interactive bool) error
- func (v *TableView) RenderKeyValue(pairs map[string]string)
- func (v *TableView) RenderPaging(data [][]string, offset, limit int, hasMore bool)
- type TextInputModel
- type WorkflowOption
Constants ¶
This section is empty.
Variables ¶
var ( // Neutral colors - use terminal's default colors BorderColor = styles.BorderInactiveColor // Base styles BaseStyle = lipgloss.NewStyle(). Padding(0, 1) // Status message styles InfoStyle = lipgloss.NewStyle(). Foreground(styles.InfoColor). Bold(true). Padding(0, 1) ErrorStyle = lipgloss.NewStyle(). Foreground(styles.ErrorColor). Bold(true). Padding(0, 1) WarningStyle = lipgloss.NewStyle(). Foreground(styles.WarningColor). Bold(true). Padding(0, 1) SuccessStyle = lipgloss.NewStyle(). Foreground(styles.SuccessColor). Bold(true). Padding(0, 1) // Interactive styles FocusedStyle = lipgloss.NewStyle(). Foreground(styles.PrimaryColor). Bold(true) BlurredStyle = lipgloss.NewStyle(). Foreground(styles.SubtleColor) // Border styles: padded but border-less BorderStyle = lipgloss.NewStyle(). Padding(1) FocusedBorderStyle = lipgloss.NewStyle(). Border(lipgloss.RoundedBorder()). BorderForeground(styles.PrimaryColor). Padding(1, 2) )
Common styles and colors for consistent theming Using ANSI colors to respect terminal color schemes
var ( EvaluationHeaderStyle = lipgloss.NewStyle(). Foreground(styles.AccentColor). Bold(true). Underline(true). Margin(1, 0) EvaluationTipStyle = lipgloss.NewStyle(). Foreground(styles.InfoColor). Italic(true). Padding(0, 1) )
Evaluation journey specific styling
Functions ¶
func ColoredText ¶
ColoredText returns text styled with the given hex color.
func ConfirmWithDefault ¶
ConfirmWithDefault shows a confirmation with a default choice
func DetectUserJourney ¶
Helper function to detect user journey from org or other data
func EvaluationConfirm ¶
EvaluationConfirm shows a confirmation with evaluation journey styling
func InlineConfirm ¶ added in v0.19.894
InlineConfirm shows a compact single-line yes/no prompt: ? Prompt (Y/n)
func ParseOrgSelection ¶
func PromptText ¶ added in v0.19.894
PromptText shows an inline text input prompt and returns the entered value.
func PromptWithAutoApprove ¶
PromptWithAutoApprove prompts for confirmation unless auto-approved or non-interactive
func RenderMarkdownTable ¶
RenderMarkdown renders a simple markdown-like table
func RunOnboarding ¶
RunOnboarding runs the onboarding flow. When interactive is false, it prints a simplified checklist to stdout.
func RunSpinnerWithContext ¶
func RunSpinnerWithContext(ctx context.Context, message string, operation func(ctx context.Context) error, json, interactive bool) error
RunSpinnerWithContext runs a spinner for the duration of a context operation.
func SelectFromItems ¶
func SelectFromItems(title string, items []SelectorItem, interactive bool) (string, error)
func SelectFromOptions ¶
func SelectInstall ¶
func SelectInstall(installs []InstallOption, interactive bool) (string, error)
func SelectWorkflow ¶
func SelectWorkflow(workflows []WorkflowOption, interactive bool) (string, error)
func ShowConfirmDialog ¶
Show displays the confirmation dialog and returns the result This provides a pterm-compatible API for easy migration
func ShowEvaluationWelcome ¶
func ShowEvaluationWelcome()
ShowEvaluationWelcome displays the evaluation welcome message
Types ¶
type ConfirmDialogModel ¶
type ConfirmDialogModel struct {
// contains filtered or unexported fields
}
ConfirmDialogModel represents an interactive confirmation dialog
func NewConfirmDialog ¶
func NewConfirmDialog(message string) ConfirmDialogModel
NewConfirmDialog creates a new confirmation dialog
func (ConfirmDialogModel) Init ¶
func (m ConfirmDialogModel) Init() tea.Cmd
Init initializes the confirmation dialog
func (ConfirmDialogModel) Result ¶
func (m ConfirmDialogModel) Result() (bool, bool)
Result returns whether the dialog was confirmed
func (ConfirmDialogModel) View ¶
func (m ConfirmDialogModel) View() tea.View
View renders the confirmation dialog
type ConfirmModel ¶
type ConfirmModel struct {
// contains filtered or unexported fields
}
ConfirmModel represents a yes/no confirmation dialog
func NewConfirmModel ¶
func NewConfirmModel(prompt string) ConfirmModel
NewConfirmModel creates a new confirmation model
func (ConfirmModel) Init ¶
func (m ConfirmModel) Init() tea.Cmd
Init initializes the confirmation model
func (ConfirmModel) Result ¶
func (m ConfirmModel) Result() bool
Result returns the confirmation result
func (ConfirmModel) Selected ¶
func (m ConfirmModel) Selected() bool
Selected returns whether a choice was made
func (ConfirmModel) View ¶
func (m ConfirmModel) View() tea.View
View renders the confirmation dialog
type FinalRenderMsg ¶
type FinalRenderMsg struct{}
FinalRenderMsg is used to trigger a final render before quitting
type InlineConfirmModel ¶ added in v0.19.894
type InlineConfirmModel struct {
// contains filtered or unexported fields
}
InlineConfirmModel is a compact single-line yes/no prompt that renders as: ? Prompt (Y/n)
func NewInlineConfirmModel ¶ added in v0.19.894
func NewInlineConfirmModel(prompt string, defaultYes bool) InlineConfirmModel
NewInlineConfirmModel creates a new inline confirmation model
func (InlineConfirmModel) Init ¶ added in v0.19.894
func (m InlineConfirmModel) Init() tea.Cmd
func (InlineConfirmModel) Result ¶ added in v0.19.894
func (m InlineConfirmModel) Result() bool
func (InlineConfirmModel) Selected ¶ added in v0.19.894
func (m InlineConfirmModel) Selected() bool
func (InlineConfirmModel) View ¶ added in v0.19.894
func (m InlineConfirmModel) View() tea.View
type InstallOption ¶
type MultiSpinnerModel ¶
type MultiSpinnerModel struct {
// contains filtered or unexported fields
}
MultiSpinnerModel manages multiple concurrent spinners
func NewMultiSpinner ¶
func NewMultiSpinner() MultiSpinnerModel
NewMultiSpinner creates a new multi-spinner model
func (*MultiSpinnerModel) AddSpinner ¶
func (m *MultiSpinnerModel) AddSpinner(id, message string)
AddSpinner adds a new spinner to the collection
func (MultiSpinnerModel) AllCompleted ¶
func (m MultiSpinnerModel) AllCompleted() bool
AllCompleted checks if all spinners are completed
func (MultiSpinnerModel) HasErrors ¶
func (m MultiSpinnerModel) HasErrors() bool
HasErrors checks if any spinners completed with errors
func (MultiSpinnerModel) Init ¶
func (m MultiSpinnerModel) Init() tea.Cmd
Init initializes all spinners
func (MultiSpinnerModel) View ¶
func (m MultiSpinnerModel) View() tea.View
View renders all spinners
type MultiSpinnerView ¶
type MultiSpinnerView struct {
// contains filtered or unexported fields
}
MultiSpinnerView provides a high-level interface for managing multiple spinners
func NewMultiSpinnerView ¶
func NewMultiSpinnerView(interactive bool) *MultiSpinnerView
NewMultiSpinnerView creates a new multi-spinner view
func (*MultiSpinnerView) AddSpinner ¶
func (v *MultiSpinnerView) AddSpinner(id, message string)
AddSpinner adds a new spinner
func (*MultiSpinnerView) AllCompleted ¶
func (v *MultiSpinnerView) AllCompleted() bool
AllCompleted checks if all spinners are completed
func (*MultiSpinnerView) CompleteSpinner ¶
func (v *MultiSpinnerView) CompleteSpinner(id string, success bool, finalMsg string)
CompleteSpinner marks a spinner as completed
func (*MultiSpinnerView) HasErrors ¶
func (v *MultiSpinnerView) HasErrors() bool
HasErrors checks if any spinners completed with errors
func (*MultiSpinnerView) Start ¶
func (v *MultiSpinnerView) Start()
Start begins the multi-spinner display
func (*MultiSpinnerView) Stop ¶
func (v *MultiSpinnerView) Stop()
Stop stops the multi-spinner display
func (*MultiSpinnerView) UpdateSpinner ¶
func (v *MultiSpinnerView) UpdateSpinner(id, message string)
UpdateSpinner updates a spinner's message
func (*MultiSpinnerView) Wait ¶
func (v *MultiSpinnerView) Wait()
Wait waits for all spinners to complete
type OnboardingModel ¶
type OnboardingModel struct {
// contains filtered or unexported fields
}
OnboardingModel represents the onboarding flow
func NewOnboardingModel ¶
func NewOnboardingModel(userJourney string) OnboardingModel
NewOnboardingModel creates a new onboarding model
func (OnboardingModel) Init ¶
func (m OnboardingModel) Init() tea.Cmd
Init initializes the onboarding model
func (OnboardingModel) View ¶
func (m OnboardingModel) View() tea.View
View renders the onboarding interface
type OnboardingStep ¶
OnboardingStep represents a single step in the onboarding flow
type RenderCompleteMsg ¶
type RenderCompleteMsg struct{}
RenderCompleteMsg is used to tell bubbletea that the final render is complete TODO(ja): lol wtf
type SelectorItem ¶
type SelectorItem struct {
// contains filtered or unexported fields
}
SelectorItem represents an item in the selector list
func (SelectorItem) Description ¶
func (i SelectorItem) Description() string
func (SelectorItem) FilterValue ¶
func (i SelectorItem) FilterValue() string
Implement list.Item interface
func (SelectorItem) IsEvaluation ¶
func (i SelectorItem) IsEvaluation() bool
func (SelectorItem) Title ¶
func (i SelectorItem) Title() string
func (SelectorItem) Value ¶
func (i SelectorItem) Value() string
type SelectorModel ¶
type SelectorModel struct {
// contains filtered or unexported fields
}
SelectorModel represents the list selection component
func NewSelectorModel ¶
func NewSelectorModel(title string, items []SelectorItem) SelectorModel
NewSelectorModel creates a new selector model
func NewSelectorModelWithMaxRows ¶
func NewSelectorModelWithMaxRows(title string, items []SelectorItem, maxVisibleRows int) SelectorModel
NewSelectorModelWithMaxRows creates a new selector model with a specific max visible rows
func (SelectorModel) Choice ¶
func (m SelectorModel) Choice() string
Choice returns the selected choice value
func (SelectorModel) Init ¶
func (m SelectorModel) Init() tea.Cmd
Init initializes the selector model
func (SelectorModel) Selected ¶
func (m SelectorModel) Selected() bool
Selected returns whether a choice was made
type SpinnerCompleteMsg ¶
SpinnerCompleteMsg is used to mark spinners as completed
type SpinnerState ¶
type SpinnerState struct {
// contains filtered or unexported fields
}
SpinnerState represents the state of an individual spinner
type SpinnerUpdateMsg ¶
SpinnerUpdateMsg is used to update spinner messages
type SpinnerView ¶
type SpinnerView struct {
// contains filtered or unexported fields
}
SpinnerView is a single-line spinner that renders directly to stdout using carriage-return overwrites. It deliberately avoids bubbletea because the v2 renderer probes for terminal capabilities at startup and the response leaks to the user's shell on short-lived programs.
func NewSpinnerView ¶
func NewSpinnerView(json, interactive bool) *SpinnerView
NewSpinnerView creates a new spinner view.
func (*SpinnerView) Fail ¶
func (v *SpinnerView) Fail(err error)
Fail completes the spinner with an error message.
func (*SpinnerView) Start ¶
func (v *SpinnerView) Start(text string)
Start begins the spinner with the given message.
func (*SpinnerView) Success ¶
func (v *SpinnerView) Success(text string)
Success completes the spinner with a success message.
func (*SpinnerView) Update ¶
func (v *SpinnerView) Update(text string)
Update changes the spinner message.
type TableModel ¶
type TableModel struct {
// contains filtered or unexported fields
}
TableModel represents a data table component
func NewInteractiveTableModel ¶
func NewInteractiveTableModel(data [][]string) TableModel
NewInteractiveTableModel creates a new interactive table model
func NewTableModel ¶
func NewTableModel(data [][]string) TableModel
NewTableModel creates a new table model
type TableView ¶
type TableView struct{}
TableView provides a high-level interface for rendering tables
func (*TableView) RenderInteractive ¶
RenderInteractive displays an interactive table that users can navigate. When interactive is false, it falls back to rendering a static table.
func (*TableView) RenderKeyValue ¶
RenderKeyValue renders key-value pairs in a table format
type TextInputModel ¶ added in v0.19.894
type TextInputModel struct {
// contains filtered or unexported fields
}
TextInputModel is a compact inline text input prompt that renders as: ? Prompt [? for help]
func NewTextInputModel ¶ added in v0.19.894
func NewTextInputModel(prompt, placeholder, help string, required bool) TextInputModel
NewTextInputModel creates a new inline text input model
func (TextInputModel) Init ¶ added in v0.19.894
func (m TextInputModel) Init() tea.Cmd
func (TextInputModel) Value ¶ added in v0.19.894
func (m TextInputModel) Value() string
Value returns the entered text
func (TextInputModel) View ¶ added in v0.19.894
func (m TextInputModel) View() tea.View