ui

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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

View Source
const MaxBranchNameWidth = 50

MaxBranchNameWidth is the maximum width for branch names before truncation

View Source
const SpinnerDelay = 1500 * time.Millisecond

SpinnerDelay is the delay before showing a spinner (only show for slow operations)

Variables

View Source
var ErrBack = fmt.Errorf("back")

ErrBack is returned when the user selects the back option

Functions

func Confirm

func Confirm(prompt string) bool

Confirm asks the user for confirmation (simple text-based)

func ConfirmTUI

func ConfirmTUI(prompt string) bool

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

func ConfirmTUIWithDefault(prompt string, defaultYes bool) bool

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

func EditWithEditor(initialContent, fileExtension string) (string, error)

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 Error

func Error(msg string)

Error prints an error message to stderr

func Hyperlink(url, text string) string

Hyperlink wraps text in OSC 8 escape sequence for clickable terminal links

func Info

func Info(msg string)

Info prints an info message to stderr

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

func Prompt(prompt, defaultVal string) string

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

func PromptPath(promptText, defaultVal string) string

PromptPath asks for a file path with tab completion support Returns the user input or the default if empty input is given

func PromptRequired

func PromptRequired(prompt string) string

PromptRequired asks for text input and keeps asking until a non-empty value is provided

func SelectBranch

func SelectBranch(branches []*config.Branch, prompt string) (*config.Branch, error)

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

func SelectOption(options []string, prompt string) (int, error)

SelectOption uses fzf to select from a list of options Returns the 0-based index of the selected option

func SelectOptionWithBack

func SelectOptionWithBack(options []string, prompt string) (int, error)

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

func SelectOptionWithSuggested(options []string, prompt string, suggestedIdx int) (int, error)

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

func SelectStack(stacks []*config.Stack, prompt string) (*config.Stack, error)

SelectStack uses fzf to select a stack

func SelectTUI

func SelectTUI(options []string, prompt string, defaultIdx int) int

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 Success

func Success(msg string)

Success prints a success message to stderr

func Warn

func Warn(msg string)

Warn prints a warning message to stderr

func WithSpinner

func WithSpinner(message string, fn func() error) error

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

type BranchWithChildInfo struct {
	Branch      *config.Branch
	HasChildren bool
}

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)

func (*DelayedSpinner) Stop

func (ds *DelayedSpinner) Stop()

Stop stops the delayed spinner

type Spinner

type Spinner struct {
	// contains filtered or unexported fields
}

Spinner represents a simple loading spinner

func NewSpinner

func NewSpinner(message string) *Spinner

NewSpinner creates a new spinner with the given message

func (*Spinner) Start

func (s *Spinner) Start()

Start begins the spinner animation

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop stops the spinner

type WorktreeInfo

type WorktreeInfo struct {
	Path   string
	Branch string
}

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"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL