Documentation
¶
Overview ¶
Package tui contains Trove's reusable Bubble Tea components: list and multi-select pickers with search/filter/pagination, text and secret inputs, a spinner, bulk-clone progress and the root dashboard.
Components render to stderr so stdout stays clean for pipes, never talk to forge providers directly (callers pass data or loader funcs in), and degrade to plain output when the session is not interactive.
Index ¶
- Variables
- func CloneProgress(ctx context.Context, t *terminal.IO, title string, names []string, ...)
- func Input(ctx context.Context, t *terminal.IO, o InputOptions) (string, error)
- func Pause(ctx context.Context, t *terminal.IO, backTo string) (bool, error)
- func Read(ctx context.Context, t *terminal.IO, doc Document, backTo string) error
- func Spin(ctx context.Context, t *terminal.IO, label string, ...) error
- func SpinValue[T any](ctx context.Context, t *terminal.IO, label string, ...) (T, error)
- type Choice
- type DashboardAction
- type DashboardData
- type DashboardOptions
- type Document
- type Facet
- type InputOptions
- type Item
- type ListOptions
- type ListResult
Constants ¶
This section is empty.
Variables ¶
var ErrQuit = errors.New("quit requested")
ErrQuit marks an abort where the user asked to leave Trove entirely (q or Ctrl+C), as opposed to going back one screen (esc). It is wrapped in an errs.ErrAborted error.
Functions ¶
func CloneProgress ¶
func CloneProgress(ctx context.Context, t *terminal.IO, title string, names []string, events <-chan services.CloneEvent)
CloneProgress consumes clone events and renders progress until events is closed. In non-interactive sessions it prints one line per finished repository to w instead of animating.
func Pause ¶
Pause waits after a view finishes so the user can read it, then reports whether they want to go back (enter/esc) or quit (q).
func Read ¶
Read shows doc full screen. It returns ErrAborted when the user goes back (esc) and an error wrapping ErrQuit when they quit (q).
Types ¶
type DashboardAction ¶
type DashboardAction string
DashboardAction is the menu entry chosen.
const ( ActionRepositories DashboardAction = "repositories" ActionPullRequests DashboardAction = "pull-requests" ActionIssues DashboardAction = "issues" ActionPipelines DashboardAction = "pipelines" ActionProviders DashboardAction = "providers" ActionSettings DashboardAction = "settings" ActionQuit DashboardAction = "quit" )
func Dashboard ¶
func Dashboard(ctx context.Context, t *terminal.IO, initial DashboardData, o DashboardOptions, load func(context.Context) DashboardData) (DashboardAction, error)
Dashboard shows the root dashboard and returns the chosen action.
type DashboardData ¶
type DashboardData struct {
ProviderLabel string // "GitHub Personal"
ProviderType string // "GitHub"
Host string
User *domain.User
Summary *domain.AccountSummary
Err error
}
DashboardData is what the dashboard shows. Loader fills it asynchronously.
type DashboardOptions ¶
type DashboardOptions struct {
// PRTerm labels the pull request count ("Open MRs"); PRLabel names the
// menu entry ("Merge Requests").
PRTerm string
PRLabel string
// Hidden actions are omitted (e.g. Issues for a provider without issues).
Hidden map[DashboardAction]bool
// RepoHint describes which repository per-repository actions use, e.g.
// "acme/api" when run inside a checkout.
RepoHint string
}
DashboardOptions tune the menu.
type Document ¶
type Document struct {
Title string
Subtitle string // e.g. "#12 · open · by alice · 2d ago"
Fields [][2]string // label/value pairs shown under the title
Body string // Markdown-ish text; rendered with light formatting
Context string // right-aligned context, e.g. "◆ GitHub Personal"
}
Document is something to read in the full-screen reader, e.g. an issue.
type Facet ¶
type Facet struct {
Key string // key in Item.Facets
Label string // "Namespace"
Binding string // single key, e.g. "f"
}
Facet is a filterable attribute cycled with a key.
type InputOptions ¶
type InputOptions struct {
Label string
Placeholder string
Default string
Help string
Secret bool // mask input; the value is never rendered
Validate func(string) error
}
InputOptions configure a text prompt.
type Item ¶
type Item struct {
ID string
Title string
Subtitle string // muted secondary text (description, host)
Badges []string // short tags such as "private", "archived"
Facets map[string]string // filterable attributes, e.g. namespace/provider
Value any
}
Item is one selectable row.
type ListOptions ¶
type ListOptions struct {
Title string
Context string // right-aligned context, e.g. "◆ GitHub Personal"
Noun string // plural noun for counts, e.g. "repositories"
Multi bool
Items []Item
Facets []Facet
Preselected map[string]bool
// ProtocolToggle shows the clone protocol and lets "t" switch it.
ProtocolToggle bool
Protocol domain.GitProtocol
// ConfirmLabel names the Enter action ("Clone", "Open", "Select").
ConfirmLabel string
// EscBack is set when the picker was opened from another screen (the
// dashboard): esc then means "back" while q still quits Trove.
EscBack bool
// SearchHint is shown while typing a search, e.g. "author:name".
SearchHint string
// InitialID places the cursor on this item (e.g. when returning to a
// list after reading one of its entries).
InitialID string
}
ListOptions configure a picker.
type ListResult ¶
type ListResult struct {
Selected []Item
Protocol domain.GitProtocol
}
ListResult is the picker outcome.
func RunList ¶
func RunList(ctx context.Context, t *terminal.IO, o ListOptions) (ListResult, error)
RunList shows a single- or multi-select picker. It returns ErrAborted if the user quits.