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 Success(msg string)
- func Warn(msg string)
- func WithSpinner(message string, fn func() error) error
- type BranchStatus
- type DelayedSpinner
- type ExitError
- type Spinner
- 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 WithSpinner ¶
WithSpinner runs a function with a delayed spinner The spinner only shows if the function takes longer than SpinnerDelay
Types ¶
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 ExitError ¶
ExitError wraps an error with a specific exit code
func NewExitError ¶
NewExitError creates an ExitError with the given code and message
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 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"