interactive

package
v2.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ReviewersHistory = util.NewHistoricalData("reviewers.history", 30)

Functions

func Confirm

func Confirm(prompt string, defaultYes bool) bool

func ConfirmOrDie

func ConfirmOrDie(prompt string, defaultYes bool)

func FormatBranchCommits added in v2.1.0

func FormatBranchCommits(branchCommits []templates.GitLog, padding string) string

FormatBranchCommits formats the additional commits on a branch for display. It copies the slice, reverses to chronological order, skips the first (which matches the main log entry), and truncates with a hiding message if needed.

func GetBranchSelectionWithFilter

func GetBranchSelectionWithFilter(branches []string, prompt string, rowEnabled func(row int) bool) ([]string, error)

GetBranchSelectionWithFilter displays an interactive selector for branches with optional filtering. The rowEnabled function can be used to disable certain rows (branches) from selection. If rowEnabled is nil, all rows are enabled. Returns an empty array if user cancelled.

func GetCommitSelection

func GetCommitSelection(options CommitSelectionOptions) ([]templates.GitLog, error)

Returns an empty array if user cancelled.

func GetLogNumberPrefix added in v2.1.0

func GetLogNumberPrefix(i int, numLogs int) string

func GetWorktreeSelection added in v2.1.1

func GetWorktreeSelection(worktrees []WorktreeOption, prompt string) (int, error)

GetWorktreeSelection displays an interactive single-select table for worktrees, showing branch and directory columns. Returns the selected index, or -1 if cancelled.

func InteractiveEnabled

func InteractiveEnabled() bool

func NewMessageKey

func NewMessageKey(keyType tea.KeyType) tea.KeyMsg

Convenience method for creating a message for when user hits a non-rune key like enter or up/down.

func NewMessageRune

func NewMessageRune(r rune) tea.KeyMsg

Convenience method for creating a message for when user typed a key.

func PromptForString

func PromptForString(prompt string, placeholder string, suggestions []string) string

func PromptForStringOrDie

func PromptForStringOrDie(prompt string, placeholder string, suggestions []string) string

func RequireInput

func RequireInput(t *testing.T)

func SendErrorOnPanic

func SendErrorOnPanic(program *tea.Program)

Returns a function that send error to the program instead of printing and calling os.Exit, as otherwise the console can be left in state where new lines are only displayed as line feeds (on Mac).

func SendToProgram

func SendToProgram(programIndex int, messages ...tea.Msg)

Sends messages to the program. Each time [NewProgram] is called after SendToProgram programIndex is incremented. This is used instead of using stdin to avoid having to (somehow?) fake keyboard scan codes. programIndex is 0 based.

func ShowLogStatus added in v2.1.0

func ShowLogStatus(logs []templates.GitLog, checkedBranches []string, pollInterval time.Duration, refreshFunc LogDataFunc, worktreeSections []WorktreeLogSection)

func UserSelection

func UserSelection() string

Types

type CommitSelectionOptions

type CommitSelectionOptions struct {
	CommitType       CommitType
	MultiSelect      bool
	Prompt           string
	GitDir           string
	DisabledBranches map[string]bool
}

type CommitSelector

type CommitSelector struct {
	SelectedRows []int
	// contains filtered or unexported fields
}

func NewCommitSelector

func NewCommitSelector(
	prompt string,
	columns []string,
	rows [][]string,
	multiselect bool,
	rowEnabled func(row int) bool,
	footer string,
) CommitSelector

func (CommitSelector) Init

func (m CommitSelector) Init() tea.Cmd

func (CommitSelector) Update

func (m CommitSelector) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (CommitSelector) View

func (m CommitSelector) View() string

type CommitType

type CommitType int
const (
	CommitTypePr CommitType = iota
	CommitTypeNoPr
	CommitTypeBoth
)

type LogDataFunc added in v2.1.0

type LogDataFunc func() ([]templates.GitLog, []string, []WorktreeLogSection)

LogDataFunc returns the current logs, checked branches, and worktree sections. It is called to refresh the log data on each poll iteration.

type ProgressIndicator

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

func NewProgressIndicator

func NewProgressIndicator(titles []string) *ProgressIndicator

* Creates one progress bar for each message.

func (*ProgressIndicator) Quit

func (p *ProgressIndicator) Quit()

func (*ProgressIndicator) SendErrorOnPanic

func (p *ProgressIndicator) SendErrorOnPanic()

func (*ProgressIndicator) SetLogLine

func (p *ProgressIndicator) SetLogLine(index int, logLine string)

func (*ProgressIndicator) SetProgress

func (p *ProgressIndicator) SetProgress(index int, progress float64)

func (*ProgressIndicator) Show

func (p *ProgressIndicator) Show()

Blocks until Quit is called.

type WorktreeLogSection added in v2.1.1

type WorktreeLogSection struct {
	DirName         string
	Logs            []templates.GitLog
	CheckedBranches []string
}

WorktreeLogSection represents commits from another worktree directory.

type WorktreeOption added in v2.1.1

type WorktreeOption struct {
	Branch string
	Path   string
}

WorktreeOption represents a worktree that can be selected.

Jump to

Keyboard shortcuts

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