Documentation
¶
Overview ¶
Package ui provides terminal UI components for wt command output.
This package uses the Charm libraries (lipgloss, bubbles) for styled terminal output including tables and spinners.
Table Formatting ¶
The primary components are table formatters for list and prune output:
- FormatListTable: Renders worktree list with ID, repo, branch, status, last commit, notes, and PR info columns
- FormatPruneTable: Simplified table for prune preview showing which worktrees will be removed and why
Tables use lipgloss styling with:
- Normal borders in gray (color 240)
- Bold headers
- Cell padding for readability
PR Status Display ¶
The list table shows PR status with visual indicators:
- "-" : No upstream branch (can't have PR)
- "?" : Not fetched yet
- State + author + comments + reviews + URL for existing PRs
- "✓" for approved, "◐" for pending reviews
Spinner (Experimental) ¶
The Spinner type wraps Bubbletea for simple non-interactive progress indication. Currently unused but available for long-running operations.
Design Notes ¶
Output is designed for terminal display with:
- Monospace font assumptions
- ANSI color support
- Truncation for long values (e.g., notes limited to 30 chars)
Index ¶
- func FormatListTable(ctx context.Context, worktrees []git.Worktree, pathToID map[string]int, ...) string
- func FormatPruneTable(worktrees []git.Worktree, pathToID map[string]int, reasonMap map[string]string, ...) string
- func FormatSummary(removed, skipped int, dryRun bool) string
- type BranchFetchResult
- type BranchFetcher
- type BranchInfo
- type CheckoutOptions
- type CheckoutWizardParams
- type ConfirmResult
- type HookInfo
- type PRFetcher
- type PrCheckoutOptions
- type PrCheckoutWizardParams
- type PruneOptions
- type PruneWizardParams
- type PruneWorktreeInfo
- type SelectResult
- type Spinner
- type TextInputResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatListTable ¶ added in v0.5.0
func FormatListTable(ctx context.Context, worktrees []git.Worktree, pathToID map[string]int, wtCache *cache.Cache) string
FormatListTable creates a formatted table for list command output
func FormatPruneTable ¶ added in v0.5.0
func FormatPruneTable(worktrees []git.Worktree, pathToID map[string]int, reasonMap map[string]string, pruneMap map[string]bool) string
FormatPruneTable creates a simplified table for prune output with reason column
func FormatSummary ¶
FormatSummary formats the summary line
Types ¶
type BranchFetchResult ¶ added in v0.8.0
type BranchFetchResult struct {
Branches []BranchInfo
}
BranchFetchResult contains branches with their worktree status.
type BranchFetcher ¶ added in v0.8.0
type BranchFetcher func(repoPath string) BranchFetchResult
BranchFetcher is a function that fetches branches for a repo path.
type BranchInfo ¶ added in v0.9.0
BranchInfo contains branch info including worktree status.
type CheckoutOptions ¶ added in v0.8.0
type CheckoutOptions struct {
Branch string
NewBranch bool
IsWorktree bool // True if selected branch already has a worktree (hooks only)
Fetch bool
Cancelled bool
SelectedRepos []string // Selected repo paths (when outside a repo)
SelectedHooks []string // Hook names to run (empty if NoHook is true)
NoHook bool // True if no hooks selected
}
CheckoutOptions holds the options gathered from interactive mode.
func CheckoutInteractive ¶ added in v0.8.0
func CheckoutInteractive(params CheckoutWizardParams) (CheckoutOptions, error)
CheckoutInteractive runs the interactive checkout wizard.
type CheckoutWizardParams ¶ added in v0.8.0
type CheckoutWizardParams struct {
Branches []BranchInfo // Existing branches with worktree status
AvailableRepos []string // All available repo paths
RepoNames []string // Display names for repos
PreSelectedRepos []int // Indices of pre-selected repos (e.g., current repo when inside one)
FetchBranches BranchFetcher
AvailableHooks []HookInfo
HooksFromCLI bool // True if --hook or --no-hook was passed (skip hooks step)
}
CheckoutWizardParams contains parameters for the checkout wizard.
type ConfirmResult ¶ added in v0.8.0
Result types for interactive prompts
func Confirm ¶ added in v0.8.0
func Confirm(prompt string) (ConfirmResult, error)
Confirm shows a yes/no prompt and returns the user's choice.
type PrCheckoutOptions ¶ added in v0.10.0
type PrCheckoutOptions struct {
Cancelled bool
SelectedRepo string // Selected repo path (when outside a repo)
SelectedPR int // Selected PR number
SelectedHooks []string // Hook names to run (empty if NoHook is true)
NoHook bool // True if no hooks selected
}
PrCheckoutOptions holds the options gathered from interactive mode.
func PrCheckoutInteractive ¶ added in v0.10.0
func PrCheckoutInteractive(params PrCheckoutWizardParams) (PrCheckoutOptions, error)
PrCheckoutInteractive runs the interactive PR checkout wizard.
type PrCheckoutWizardParams ¶ added in v0.10.0
type PrCheckoutWizardParams struct {
AvailableRepos []string // All available repo paths
RepoNames []string // Display names for repos
PreSelectedRepo int // Index of pre-selected repo (-1 if none)
FetchPRs PRFetcher // Function to fetch PRs for a repo
AvailableHooks []HookInfo // Available hooks
HooksFromCLI bool // True if --hook or --no-hook was passed (skip hooks step)
}
PrCheckoutWizardParams contains parameters for the PR checkout wizard.
type PruneOptions ¶ added in v0.9.0
PruneOptions holds the options gathered from interactive mode.
func PruneInteractive ¶ added in v0.9.0
func PruneInteractive(params PruneWizardParams) (PruneOptions, error)
PruneInteractive runs the interactive prune wizard.
type PruneWizardParams ¶ added in v0.9.0
type PruneWizardParams struct {
Worktrees []PruneWorktreeInfo // All worktrees with their prune status
IncludeClean bool // Whether -c flag was set (affects which are pre-selected)
}
PruneWizardParams contains parameters for the prune wizard.
type PruneWorktreeInfo ¶ added in v0.9.0
type PruneWorktreeInfo struct {
ID int
RepoName string
Branch string
Reason string // "Merged PR", "Merged branch", "Clean", "Dirty", "Not merged", "Has commits"
IsDirty bool // Whether worktree has uncommitted changes
Worktree git.Worktree
}
PruneWorktreeInfo contains worktree data for display in the wizard.
type SelectResult ¶ added in v0.8.0
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner wraps a Bubbletea spinner for simple non-interactive use
func NewSpinner ¶
NewSpinner creates a new spinner with the given message
func (*Spinner) UpdateMessage ¶
UpdateMessage changes the spinner message
type TextInputResult ¶ added in v0.8.0
func TextInput ¶ added in v0.8.0
func TextInput(prompt, placeholder string) (TextInputResult, error)
TextInput shows a text input prompt and returns the user's input.