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 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 SelectBranchForDeletion(branches []BranchWithChildInfo, prompt string) (*config.Branch, bool, 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 BranchWithChildInfo
- type DelayedSpinner
- 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 ( IconSuccess = "\uf00c" // nf-fa-check IconError = "\uf00d" // nf-fa-times IconWarning = "\uf071" // nf-fa-exclamation_triangle IconInfo = "\uf05a" // nf-fa-info_circle IconPending = "\uf192" // nf-fa-dot_circle_o IconArrow = "\uf061" // nf-fa-arrow_right IconPointer = "\uf0a4" // nf-fa-hand_o_right IconBranch = "\ue725" // nf-dev-git_branch IconUp = "\uf062" // nf-fa-arrow_up IconDown = "\uf063" // nf-fa-arrow_down IconSync = "\uf021" // nf-fa-refresh IconCancel = "\uf05e" // nf-fa-ban IconBullet = "\uf111" // nf-fa-circle IconApproved = "\uf058" // nf-fa-check_circle IconChanges = "\uf06a" // nf-fa-exclamation_circle IconConflict = "\uf071" // nf-fa-exclamation_triangle IconNew = "\uf067" // nf-fa-plus IconPush = "\uf093" // nf-fa-upload IconStack = "\uf24d" // nf-fa-clone (stack of items) IconRocket = "\uf135" // nf-fa-rocket IconBack = "\uf060" // nf-fa-arrow_left IconRemote = "\uf0c1" // nf-fa-link (for remote branches) )
Nerd Font icons for consistent terminal rendering
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 ErrBack = fmt.Errorf("back")
ErrBack is returned when the user selects the back option
Functions ¶
func ConfirmTUI ¶
ConfirmTUI shows a nice TUI confirmation dialog with arrow key navigation Returns true if user confirms, false otherwise Yes is selected by default
func ConfirmTUIWithDefault ¶
ConfirmTUIWithDefault shows a nice TUI confirmation dialog with arrow key navigation Returns true if user confirms, false otherwise defaultYes controls which option is selected by 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 PrintStack ¶
func PrintStack(stack *config.Stack, currentBranch string, showStatus bool, statusMap map[string]*BranchStatus)
PrintStack prints a visual representation of a stack, always sorting topologically If showStatus is true, includes CI/PR status column Column layout: - showStatus=false: 4 columns - branch name, pr number, parent branch, remote tag - showStatus=true: 5 columns - branch name, pr number, ci status, parent branch, remote tag
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 SelectBranchForDeletion ¶
func SelectBranchForDeletion(branches []BranchWithChildInfo, prompt string) (*config.Branch, bool, error)
SelectBranchForDeletion uses fzf to select a branch for deletion Branches are shown in two sections: 1. Branches without children (safe to delete) 2. Branches with children (with a warning header) Returns the selected branch, whether it has children, and any error
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", ""
}
BranchStatus contains status information for a branch
type BranchWithChildInfo ¶
BranchWithChildInfo holds branch info for deletion selection
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 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"