Documentation
¶
Index ¶
- Constants
- Variables
- func Confirm(prompt string) bool
- func ConfirmTUI(prompt string) bool
- func ConfirmTUIWithDefault(prompt string, defaultYes bool) bool
- func EditWithEditor(initialContent, fileExtension string) (string, error)
- func Error(msg string)
- func GetExitCode(err error) int
- func Hyperlink(url, text string) string
- func Info(msg string)
- func PrintStack(stack *config.Stack, currentBranch string, showStatus bool, ...)
- func Prompt(prompt, defaultVal string) string
- func PromptPath(promptText, defaultVal string) string
- func PromptRequired(prompt string) string
- func SelectBranch(branches []*config.Branch, prompt string) (*config.Branch, error)
- func SelectBranchWithStacks(branches []*config.Branch, stacks []*config.Stack, prompt string) (*config.Branch, error)
- func SelectOption(options []string, prompt string) (int, error)
- func SelectOptionWithBack(options []string, prompt string) (int, error)
- func SelectOptionWithSuggested(options []string, prompt string, suggestedIdx int) (int, error)
- func SelectStack(stacks []*config.Stack, prompt string) (*config.Stack, error)
- func SelectTUI(options []string, prompt string, defaultIdx int) int
- func SetBackend(b Backend)
- func Success(msg string)
- func SuggestCommand(input string, candidates []string) string
- func Warn(msg string)
- func WithSpinner(message string, fn func() error) error
- type Backend
- type BranchStatus
- type DelayedSpinner
- type ElicitFunc
- type ElicitResult
- type ExitError
- type MCPBackend
- func (m *MCPBackend) Confirm(prompt string) bool
- func (m *MCPBackend) ConfirmWithDefault(prompt string, defaultYes bool) bool
- func (m *MCPBackend) Prompt(prompt, defaultVal string) string
- func (m *MCPBackend) PromptRequired(prompt string) string
- func (m *MCPBackend) Select(options []string, prompt string, defaultIdx int) int
- func (m *MCPBackend) SelectBranch(branches []*config.Branch, prompt string) (*config.Branch, error)
- func (m *MCPBackend) SelectOption(options []string, prompt string) (int, error)
- func (m *MCPBackend) SelectOptionWithBack(options []string, prompt string) (int, error)
- func (m *MCPBackend) SelectStack(stacks []*config.Stack, prompt string) (*config.Stack, error)
- type Spinner
- type TerminalBackend
- func (t *TerminalBackend) Confirm(prompt string) bool
- func (t *TerminalBackend) ConfirmWithDefault(prompt string, defaultYes bool) bool
- func (t *TerminalBackend) Prompt(prompt, defaultVal string) string
- func (t *TerminalBackend) PromptRequired(prompt string) string
- func (t *TerminalBackend) Select(options []string, prompt string, defaultIdx int) int
- func (t *TerminalBackend) SelectBranch(branches []*config.Branch, prompt string) (*config.Branch, error)
- func (t *TerminalBackend) SelectOption(options []string, prompt string) (int, error)
- func (t *TerminalBackend) SelectOptionWithBack(options []string, prompt string) (int, error)
- func (t *TerminalBackend) SelectStack(stacks []*config.Stack, prompt string) (*config.Stack, error)
- type WorktreeInfo
Constants ¶
const ( Reset = "\033[0m" Bold = "\033[1m" Strikethrough = "\033[9m" Red = "\033[31m" Green = "\033[32m" Yellow = "\033[33m" Blue = "\033[34m" Magenta = "\033[35m" Cyan = "\033[36m" Gray = "\033[90m" )
Colors for terminal output
const ( ExitSuccess = 0 // Success ExitGeneral = 1 // General error ExitUsage = 2 // Usage/argument error ExitConflict = 3 // Rebase conflict ExitNotInRepo = 4 // Not in a git repository ExitNotInStack = 5 // Current branch is not in a stack ExitAuthRequired = 6 // GitHub authentication required ExitBranchNotFound = 7 // Branch not found ExitNetworkError = 8 // Network/remote error ExitUserCancelled = 10 // User cancelled operation )
Exit codes for structured error reporting
const MaxBranchNameWidth = 50
MaxBranchNameWidth is the maximum width for branch names before truncation
const SpinnerDelay = 1500 * time.Millisecond
SpinnerDelay is the delay before showing a spinner (only show for slow operations)
Variables ¶
var ( IconSuccess = "\uf00c" IconError = "\uf00d" IconWarning = "\uf071" IconInfo = "\uf05a" IconPending = "\uf192" IconArrow = "\uf061" IconPointer = "\uf0a4" IconBranch = "\ue725" IconUp = "\uf062" IconDown = "\uf063" IconSync = "\uf021" IconCancel = "\uf05e" IconBullet = "\uf111" IconApproved = "\uf058" IconChanges = "\uf06a" IconConflict = "\uf071" IconNew = "\uf067" IconPush = "\uf093" IconStack = "\uf24d" IconRocket = "\uf135" IconBack = "\uf060" )
Icons for terminal rendering. Defaults to Nerd Font glyphs; set EZS_ASCII=1 to use plain ASCII fallbacks.
var ErrBack = fmt.Errorf("back")
ErrBack is returned when the user selects the back option
var YesMode bool
YesMode, when true, makes all ConfirmTUI / Confirm calls auto-return true without showing any interactive dialog.
Functions ¶
func ConfirmTUI ¶
ConfirmTUI shows a TUI yes/no dialog with Yes highlighted by default. ESC cancels (returns false).
func ConfirmTUIWithDefault ¶
ConfirmTUIWithDefault shows a TUI yes/no dialog. defaultYes controls which option is highlighted; ESC returns the default.
func EditWithEditor ¶
EditWithEditor opens the user's preferred editor with the initial content and returns the edited content. If the user saves and exits, the content is returned. If the user aborts (empty file or error), an error is returned. The editor is determined by $EDITOR, $VISUAL, or falls back to "vim".
func GetExitCode ¶
GetExitCode returns the exit code for an error, defaulting to ExitGeneral
func PrintStack ¶
func PrintStack(stack *config.Stack, currentBranch string, showStatus bool, statusMap map[string]*BranchStatus)
PrintStack prints a visual representation of a stack using tree-style indentation. If showStatus is true, includes CI/PR status after the PR column.
func Prompt ¶
Prompt asks for text input with a prompt and optional default value Returns the user input or the default if empty input is given
func PromptPath ¶
PromptPath asks for a file path with tab completion support Returns the user input or the default if empty input is given
func PromptRequired ¶
PromptRequired asks for text input and keeps asking until a non-empty value is provided
func SelectBranch ¶
SelectBranch uses fzf to select a branch from a list
func SelectBranchWithStacks ¶
func SelectBranchWithStacks(branches []*config.Branch, stacks []*config.Stack, prompt string) (*config.Branch, error)
SelectBranchWithStacks uses fzf to select a branch with optional stack preview
func SelectOption ¶
SelectOption uses fzf to select from a list of options Returns the 0-based index of the selected option
func SelectOptionWithBack ¶
SelectOptionWithBack uses fzf to select from a list of options with a back option. Returns the 0-based index of the selected option, or ErrBack if back was selected. The back option is displayed as an unnumbered "← back" at the end of the list.
func SelectOptionWithSuggested ¶
SelectOptionWithSuggested uses fzf to select from a list of options suggestedIdx is the 0-based index of the suggested option (-1 for none) The suggested option will be marked with "(suggested)" and appear first Returns the 0-based index of the selected option
func SelectStack ¶
SelectStack uses fzf to select a stack
func SelectTUI ¶
SelectTUI shows a TUI selection menu with arrow key navigation options is the list of options to display prompt is the question to ask defaultIdx is the 0-based index of the default selected option Returns the 0-based index of the selected option, or -1 if cancelled
func SetBackend ¶ added in v4.4.0
func SetBackend(b Backend)
SetBackend replaces the active UI backend (e.g. to MCPBackend for MCP mode).
func SuggestCommand ¶ added in v4.7.0
SuggestCommand returns the candidate with the smallest Levenshtein distance to input, provided the distance is plausibly a typo (≤3 and ≤ half the longer of the two strings). Returns "" when nothing qualifies, the input is empty, or the candidate list is empty.
func WithSpinner ¶
WithSpinner runs a function with a delayed spinner The spinner only shows if the function takes longer than SpinnerDelay
Types ¶
type Backend ¶ added in v4.4.0
type Backend interface {
// Confirm asks a yes/no question, defaulting to yes.
Confirm(prompt string) bool
// ConfirmWithDefault asks a yes/no question with a configurable default.
ConfirmWithDefault(prompt string, defaultYes bool) bool
// Select shows a selection menu and returns the 0-based index, or -1 if cancelled.
Select(options []string, prompt string, defaultIdx int) int
// SelectOption presents options via fzf-style selection and returns the 0-based index.
SelectOption(options []string, prompt string) (int, error)
// SelectOptionWithBack is like SelectOption but includes a "back" option.
// Returns ErrBack if back was selected.
SelectOptionWithBack(options []string, prompt string) (int, error)
// SelectBranch selects a branch from a list.
SelectBranch(branches []*config.Branch, prompt string) (*config.Branch, error)
// SelectStack selects a stack from a list.
SelectStack(stacks []*config.Stack, prompt string) (*config.Stack, error)
// Prompt asks for text input with an optional default value.
Prompt(prompt, defaultVal string) string
// PromptRequired asks for text input, requiring a non-empty response.
PromptRequired(prompt string) string
}
Backend defines the interface for interactive user prompts. Implementations include the terminal TUI (default) and MCP elicitation.
type BranchStatus ¶
type BranchStatus struct {
PRState string // "OPEN", "MERGED", "CLOSED", "DRAFT", ""
CIState string // "success", "failure", "pending", "none", ""
CISummary string // e.g., "3/3 passed"
Mergeable string // "MERGEABLE", "CONFLICTING", "UNKNOWN"
ReviewState string // "APPROVED", "CHANGES_REQUESTED", "REVIEW_REQUIRED", ""
Additions int // Lines added relative to parent
Deletions int // Lines removed relative to parent
}
BranchStatus contains status information for a branch
type DelayedSpinner ¶
type DelayedSpinner struct {
// contains filtered or unexported fields
}
DelayedSpinner represents a spinner that only shows after a delay
func NewDelayedSpinner ¶
func NewDelayedSpinner(message string) *DelayedSpinner
NewDelayedSpinner creates a spinner that only shows after the configured delay
func (*DelayedSpinner) Start ¶
func (ds *DelayedSpinner) Start()
Start begins the delayed spinner (will only show if not stopped before delay)
type ElicitFunc ¶ added in v4.4.0
type ElicitFunc func(message string, schema map[string]interface{}) (*ElicitResult, error)
ElicitFunc sends an elicitation request to the MCP client. message is displayed to the user; schema is a JSON Schema for the form.
type ElicitResult ¶ added in v4.4.0
type ElicitResult struct {
Action string // "accept", "decline", or "cancel"
Content map[string]interface{} // Form data; present only when Action is "accept"
}
ElicitResult holds the response from an MCP elicitation request.
type ExitError ¶
ExitError wraps an error with a specific exit code
func NewExitError ¶
NewExitError creates an ExitError with the given code and message
type MCPBackend ¶ added in v4.4.0
type MCPBackend struct {
Elicit ElicitFunc
}
MCPBackend implements Backend using MCP elicitation.
func (*MCPBackend) Confirm ¶ added in v4.4.0
func (m *MCPBackend) Confirm(prompt string) bool
func (*MCPBackend) ConfirmWithDefault ¶ added in v4.4.0
func (m *MCPBackend) ConfirmWithDefault(prompt string, defaultYes bool) bool
func (*MCPBackend) Prompt ¶ added in v4.4.0
func (m *MCPBackend) Prompt(prompt, defaultVal string) string
func (*MCPBackend) PromptRequired ¶ added in v4.4.0
func (m *MCPBackend) PromptRequired(prompt string) string
func (*MCPBackend) Select ¶ added in v4.4.0
func (m *MCPBackend) Select(options []string, prompt string, defaultIdx int) int
func (*MCPBackend) SelectBranch ¶ added in v4.4.0
func (*MCPBackend) SelectOption ¶ added in v4.4.0
func (m *MCPBackend) SelectOption(options []string, prompt string) (int, error)
func (*MCPBackend) SelectOptionWithBack ¶ added in v4.4.0
func (m *MCPBackend) SelectOptionWithBack(options []string, prompt string) (int, error)
func (*MCPBackend) SelectStack ¶ added in v4.4.0
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner represents a simple loading spinner
func NewSpinner ¶
NewSpinner creates a new spinner with the given message
type TerminalBackend ¶ added in v4.4.0
type TerminalBackend struct{}
TerminalBackend is the default Backend backed by the terminal TUI.
func (*TerminalBackend) Confirm ¶ added in v4.4.0
func (t *TerminalBackend) Confirm(prompt string) bool
func (*TerminalBackend) ConfirmWithDefault ¶ added in v4.4.0
func (t *TerminalBackend) ConfirmWithDefault(prompt string, defaultYes bool) bool
func (*TerminalBackend) Prompt ¶ added in v4.4.0
func (t *TerminalBackend) Prompt(prompt, defaultVal string) string
func (*TerminalBackend) PromptRequired ¶ added in v4.4.0
func (t *TerminalBackend) PromptRequired(prompt string) string
func (*TerminalBackend) Select ¶ added in v4.4.0
func (t *TerminalBackend) Select(options []string, prompt string, defaultIdx int) int
func (*TerminalBackend) SelectBranch ¶ added in v4.4.0
func (*TerminalBackend) SelectOption ¶ added in v4.4.0
func (t *TerminalBackend) SelectOption(options []string, prompt string) (int, error)
func (*TerminalBackend) SelectOptionWithBack ¶ added in v4.4.0
func (t *TerminalBackend) SelectOptionWithBack(options []string, prompt string) (int, error)
func (*TerminalBackend) SelectStack ¶ added in v4.4.0
type WorktreeInfo ¶
WorktreeInfo represents a worktree for UI selection
func SelectWorktree ¶
func SelectWorktree(worktrees []WorktreeInfo, prompt string) (*WorktreeInfo, error)
SelectWorktree uses fzf to select a worktree from a list
func SelectWorktreeWithStackPreview ¶
func SelectWorktreeWithStackPreview(worktrees []WorktreeInfo, stacks []*config.Stack, prompt string) (*WorktreeInfo, error)
SelectWorktreeWithStackPreview uses fzf to select a worktree with stack preview For worktrees not in any stack, the preview shows "Not part of a stack"