Documentation
¶
Index ¶
- Constants
- type ConfirmModel
- type LoginFlowModel
- type LoginFlowOptions
- type LoginMethod
- type LoginResult
- type MarkdownViewportModel
- type PreambleModel
- type PromptModel
- type RunGetAction
- type RunGetExecution
- type RunGetFlowModel
- type RunGetFlowOptions
- type RunGetItem
- type RunGetResult
- type RunGetStepItem
- type RunGetTestItem
- type SecretModel
- type SelectModel
- type SpinnerModel
- type ThemePickerModel
Constants ¶
MarkdownViewportFooterHeight is the number of rows reserved below the viewport for the footer (one blank separator row + the help line). Callers use it to decide whether content fits on one screen.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfirmModel ¶
type ConfirmModel struct {
// contains filtered or unexported fields
}
ConfirmModel is a bubbletea model for a y/N confirmation prompt. Press y/Y to confirm, n/N/esc/ctrl+c to decline.
func NewConfirmModel ¶
func NewConfirmModel(prompt string) ConfirmModel
func (ConfirmModel) Confirmed ¶
func (m ConfirmModel) Confirmed() bool
func (ConfirmModel) Done ¶
func (m ConfirmModel) Done() bool
func (ConfirmModel) Init ¶
func (m ConfirmModel) Init() tea.Cmd
func (ConfirmModel) View ¶
func (m ConfirmModel) View() tea.View
type LoginFlowModel ¶
type LoginFlowModel struct {
// contains filtered or unexported fields
}
LoginFlowModel is a multi-stage bubbletea model that walks the user through CircleCI authentication:
- Pick a CircleCI host (circleci.com or a custom URL).
- Pick an auth method (browser OAuth or paste a token). 3a. For browser OAuth: press Enter → open browser → wait for callback. 3b. For token: type/paste the personal access token.
After tea.Program.Run() returns, call Result() to read the outcome and Close() to release the OAuth server if one was started.
func NewLoginFlow ¶
func NewLoginFlow(ctx context.Context, opts LoginFlowOptions) LoginFlowModel
NewLoginFlow returns a LoginFlowModel ready to pass to tea.NewProgram.
func (LoginFlowModel) Close ¶
func (m LoginFlowModel) Close()
Close shuts down the OAuth callback server if one was started.
func (LoginFlowModel) Init ¶
func (m LoginFlowModel) Init() tea.Cmd
func (LoginFlowModel) Result ¶
func (m LoginFlowModel) Result() LoginResult
Result returns the final login outcome. Only valid after tea.Program.Run() returns.
func (LoginFlowModel) View ¶
func (m LoginFlowModel) View() tea.View
type LoginFlowOptions ¶
type LoginFlowOptions struct {
DeviceID string
OSInfo string
Signup bool
CallbackTimeout time.Duration
// GetUser, if non-nil, is called after token exchange to display
// the authenticated user's login name.
GetUser func(ctx context.Context, host, token string) (id uuid.UUID, username string, err error)
Color bool
}
LoginFlowOptions configures a LoginFlowModel.
type LoginMethod ¶
type LoginMethod int
LoginMethod indicates which authentication path the user selected.
const (
LoginMethodBrowser LoginMethod = iota
)
LoginMethodBrowser selects the browser-based OAuth PKCE flow.
type LoginResult ¶
type LoginResult struct {
Cancelled bool
Host string // resolved base URL
Token string // set when auth succeeds (either method)
UserID uuid.UUID // set when GetUser is provided and succeeds
Username string // set when GetUser is provided and succeeds
Err error
}
LoginResult is the outcome of a completed LoginFlowModel run.
type MarkdownViewportModel ¶
type MarkdownViewportModel struct {
// contains filtered or unexported fields
}
MarkdownViewportModel is a full-screen pager for rendered markdown. It puts the content in a scrollable viewport with a footer showing scroll position and key hints, modelled on the bubbletea glamour example.
Content is produced by a render callback so the markdown can be re-wrapped to the live terminal width whenever the window is resized.
func NewMarkdownViewportModel ¶
func NewMarkdownViewportModel(render func(width int) string) MarkdownViewportModel
NewMarkdownViewportModel returns a pager that displays the markdown produced by render. render is given the column width the content must fit into.
func (MarkdownViewportModel) Init ¶
func (m MarkdownViewportModel) Init() tea.Cmd
func (MarkdownViewportModel) View ¶
func (m MarkdownViewportModel) View() tea.View
type PreambleModel ¶
type PreambleModel struct {
// contains filtered or unexported fields
}
PreambleModel is a bubbletea model for an "Enter to continue · Esc to cancel" gate shown before a multi-step orchestrator runs. Default is opt-in: Enter proceeds, Esc/Ctrl+C cancels.
func NewPreambleModel ¶
func NewPreambleModel(title, dir string, bullets []string) PreambleModel
NewPreambleModel returns a PreambleModel rendering the given title, bullet lines, and directory context.
func (PreambleModel) Done ¶
func (m PreambleModel) Done() bool
Done reports whether the user has made a choice.
func (PreambleModel) Init ¶
func (m PreambleModel) Init() tea.Cmd
func (PreambleModel) Proceed ¶
func (m PreambleModel) Proceed() bool
Proceed reports whether the user pressed Enter to continue. False when cancelled via Esc or Ctrl+C.
func (PreambleModel) View ¶
func (m PreambleModel) View() tea.View
type PromptModel ¶
type PromptModel struct {
// contains filtered or unexported fields
}
PromptModel is a bubbletea model for prompting a single line of plain (non-secret) text. Esc / Ctrl+C cancel. Enter confirms.
func NewPromptModel ¶
func NewPromptModel(header, placeholder, defaultVal string) PromptModel
NewPromptModel creates a PromptModel with the given header, an optional placeholder shown inside the empty input field, and an optional default value accepted when the user presses Enter with an empty field.
func (PromptModel) Init ¶
func (m PromptModel) Init() tea.Cmd
func (PromptModel) Quitting ¶
func (m PromptModel) Quitting() bool
Quitting reports whether the user pressed Esc or Ctrl+C without confirming.
func (PromptModel) View ¶
func (m PromptModel) View() tea.View
type RunGetAction ¶
type RunGetAction int
RunGetAction is the terminal choice the user reached in the run-get flow.
const ( // RunGetActionCancel means the user quit (esc on the first picker, ctrl+c // anywhere) without choosing what to display. RunGetActionCancel RunGetAction = iota // RunGetActionShowRun displays the whole run (all its workflows). RunGetActionShowRun // RunGetActionShowWorkflow displays a single workflow (all its jobs). RunGetActionShowWorkflow // RunGetActionShowJob displays a single job. RunGetActionShowJob // RunGetActionShowJobOutput displays the full per-step output report for a // job (the equivalent of "circleci job output list"). RunGetActionShowJobOutput )
type RunGetExecution ¶
type RunGetExecution struct {
Label string
Icon string
Index int
Steps []RunGetStepItem
}
RunGetExecution is one parallel execution of a job, carrying its steps. When a job's parallelism is greater than one the flow inserts an execution picker before the step picker; with a single execution that picker is skipped.
type RunGetFlowModel ¶
type RunGetFlowModel struct {
// contains filtered or unexported fields
}
RunGetFlowModel is a single multi-stage bubbletea program that drives the interactive "circleci run get" flow by composing components.SelectModel and a spinner:
- Pick a run from the recent list.
- Pick a workflow, or "see all workflows" (→ RunGetActionShowRun).
- Pick a job, or "all jobs in workflow" (→ RunGetActionShowWorkflow).
- For a job with parallelism > 1, pick an execution (skipped otherwise).
- Pick a step, or one of three summaries — "job report" (→ RunGetActionShowJob), the full per-step output report (→ RunGetActionShowJobOutput), or "failed tests", which opens a further picker of the job's failed tests. The cursor starts on the first failed step. Picking a step opens its output in an in-flow pager (r refreshes, esc returns to the step picker) rather than ending the program.
- From the failed-tests picker, picking a test opens its message in the same pager (esc returns to the test picker).
Between selections the next level's items are fetched off the Update loop via a tea.Cmd, with a spinner shown meanwhile. esc moves back one step (on the first picker it quits); ctrl+c quits anywhere. After Run() returns, read the outcome with Result(); the caller then prints the corresponding summary.
func NewRunGetFlow ¶
func NewRunGetFlow(ctx context.Context, opts RunGetFlowOptions) RunGetFlowModel
NewRunGetFlow returns a RunGetFlowModel ready to pass to tea.NewProgram.
func (RunGetFlowModel) Init ¶
func (m RunGetFlowModel) Init() tea.Cmd
func (RunGetFlowModel) Result ¶
func (m RunGetFlowModel) Result() RunGetResult
Result returns the final outcome. Only valid after tea.Program.Run() returns.
func (RunGetFlowModel) View ¶
func (m RunGetFlowModel) View() tea.View
type RunGetFlowOptions ¶
type RunGetFlowOptions struct {
Runs []RunGetItem
FetchWorkflows func(ctx context.Context, runID uuid.UUID) ([]RunGetItem, error)
FetchJobs func(ctx context.Context, workflowID uuid.UUID) ([]RunGetItem, error)
FetchExecutions func(ctx context.Context, jobID uuid.UUID) ([]RunGetExecution, error)
// FetchStepStdout reads a step's stdout from byte offset, returning the new
// bytes (raw, ANSI intact) and whether stdout has finished. The pager polls
// this until terminal. FetchStepStderr reads the step's full stderr once
// stdout terminates (stdout always completes first).
FetchStepStdout func(ctx context.Context, jobID uuid.UUID, execution, stepNum int, offset int64) (data []byte, terminal bool, err error)
FetchStepStderr func(ctx context.Context, jobID uuid.UUID, execution, stepNum int) ([]byte, error)
// FetchFailedTests lists a job's failed tests for the "failed tests" picker.
// Each item carries the message shown in the pager when the test is picked.
FetchFailedTests func(ctx context.Context, jobID uuid.UUID) ([]RunGetTestItem, error)
Color bool
// Animate reports whether the loading spinner should animate. Pass false when
// CIRCLE_SPINNER_DISABLED is set (or the session is non-interactive) so the
// loading line stays static instead of repainting.
Animate bool
// CurrentBranch is the branch the initial Runs were fetched for.
// DefaultBranch is the project's default branch. When the two differ, the run
// picker offers a shift+tab toggle between them, re-fetching via FetchRuns.
// When DefaultBranch is empty or equal to CurrentBranch, the toggle is hidden.
CurrentBranch string
DefaultBranch string
FetchRuns func(ctx context.Context, branch string) ([]RunGetItem, error)
}
RunGetFlowOptions configures a RunGetFlowModel. The fetch callbacks keep this program decoupled from the API client: the caller supplies the already-built run list and closures that return the next level's items on demand.
type RunGetItem ¶
RunGetItem is one selectable row: a display label, an optional status symbol (uncolored — the flow colors it when color is enabled), and the UUID it maps to.
type RunGetResult ¶
type RunGetResult struct {
Action RunGetAction
RunID uuid.UUID
WorkflowID uuid.UUID
JobID uuid.UUID
// Err is set when a mid-flow fetch (workflows, jobs or steps) failed; Action
// is RunGetActionCancel in that case.
Err error
}
RunGetResult is the outcome of a completed RunGetFlowModel run, read via Result() after tea.Program.Run() returns.
type RunGetStepItem ¶
RunGetStepItem is one selectable job step. Steps have no UUID; they are addressed by their parallel-execution index and step number.
type RunGetTestItem ¶
RunGetTestItem is one selectable failed test: a display label, a status symbol, and the test's message shown in the pager when the row is picked.
type SecretModel ¶
type SecretModel struct {
// contains filtered or unexported fields
}
SecretModel is a bubbletea model for prompting a secret value. Input is masked (echo password mode). The prompt header is configurable so callers can name the specific secret being requested.
func NewSecretModel ¶
func NewSecretModel(header string) SecretModel
NewSecretModel creates a SecretModel with the given header text.
func (SecretModel) Init ¶
func (m SecretModel) Init() tea.Cmd
func (SecretModel) Quitting ¶
func (m SecretModel) Quitting() bool
Quitting reports whether the user pressed Esc or Ctrl+C.
func (SecretModel) Value ¶
func (m SecretModel) Value() string
Value returns the entered secret value.
func (SecretModel) View ¶
func (m SecretModel) View() tea.View
type SelectModel ¶
type SelectModel struct {
// contains filtered or unexported fields
}
SelectModel is a top-level bubbletea model that wraps components.SelectModel and quits the program on selection or cancellation.
func NewSelectModel ¶
func NewSelectModel(prompt string, options []string) SelectModel
NewSelectModel creates a standalone select prompt. options is the list of choices to display.
func (SelectModel) Cancelled ¶
func (m SelectModel) Cancelled() bool
Cancelled reports whether the user quit without selecting.
func (SelectModel) Init ¶
func (m SelectModel) Init() tea.Cmd
func (SelectModel) Selected ¶
func (m SelectModel) Selected() int
Selected returns the index of the chosen option. Only valid when !Cancelled().
func (SelectModel) View ¶
func (m SelectModel) View() tea.View
func (SelectModel) WithCursor ¶
func (m SelectModel) WithCursor(i int) SelectModel
WithCursor returns a copy of the model with the initial highlighted option set to index i. Use this to pre-select a default choice.
type SpinnerModel ¶
type SpinnerModel struct {
// contains filtered or unexported fields
}
SpinnerModel is a bubbletea model that displays an animated spinner with a message. Run it in a goroutine via tea.NewProgram; call p.Quit() to stop it.
func NewSpinnerModel ¶
func NewSpinnerModel(msg string, color bool) SpinnerModel
func (SpinnerModel) Init ¶
func (m SpinnerModel) Init() tea.Cmd
func (SpinnerModel) View ¶
func (m SpinnerModel) View() tea.View
type ThemePickerModel ¶
type ThemePickerModel struct {
// contains filtered or unexported fields
}
ThemePickerModel is a top-level bubbletea program that splits the screen horizontally: the left pane is the standard select list of theme names, and the right pane shows sample markdown rendered in the currently-highlighted theme. Moving the cursor re-renders the preview, so the user sees each theme applied live before committing. Enter confirms; Esc/Ctrl+C cancels.
The markdown is produced by a render callback so the program stays decoupled from glamour: the caller (iostream) supplies a closure that renders the sample in a given theme, wrapped to a given width.
func NewThemePickerModel ¶
func NewThemePickerModel(prompt string, labels, themes []string, render func(theme string, width int) string, color, animate bool) ThemePickerModel
NewThemePickerModel builds a theme picker. labels are the display strings for the list (e.g. with a "(default)" marker); themes are the matching raw theme names, same length and order. render produces the preview markdown for a theme at a given width. animate reports whether the loading spinner should be animated. Pass false when CIRCLE_SPINNER_DISABLED is set or output is non-interactive, so the placeholder stays static.
func (ThemePickerModel) Cancelled ¶
func (m ThemePickerModel) Cancelled() bool
Cancelled reports whether the user quit without selecting.
func (ThemePickerModel) Init ¶
func (m ThemePickerModel) Init() tea.Cmd
Init starts the spinner ticking so the loading placeholder animates. The spinner self-schedules its next tick, so a single Tick here keeps it running for the lifetime of the program. When animation is disabled it stays still, so scripted or non-TTY sessions see a stable screen.
func (ThemePickerModel) Selected ¶
func (m ThemePickerModel) Selected() int
Selected returns the index of the chosen theme. Only valid when !Cancelled().
func (ThemePickerModel) View ¶
func (m ThemePickerModel) View() tea.View
func (ThemePickerModel) WithCursor ¶
func (m ThemePickerModel) WithCursor(i int) ThemePickerModel
WithCursor returns a copy with the initial highlighted option at index i. Use this to start on the current theme.