ui

package
v0.0.0-...-670fc63 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUserQuit = errors.New("user quit")

ErrUserQuit is returned by Run when the user chooses to quit without committing.

Functions

func FormatMessage

func FormatMessage(message string) string

FormatMessage returns the message wrapped in display borders.

func Run

func Run(opts RunOpts) error

Run displays the message and runs the interactive menu loop until the user accepts, quits, or an error occurs.

func RunSelector

func RunSelector(entries []FileEntry) ([]string, error)

RunSelector displays an interactive file selector and returns the paths the user selected. It returns ErrUserQuit if the user cancels.

Types

type Choice

type Choice int

Choice represents what the user chose in the menu.

const (
	ChoiceUnknown       Choice = iota
	ChoiceAccept               // a — commit as-is
	ChoiceAcceptAndPush        // A — commit and push
	ChoiceEdit                 // e — open $EDITOR
	ChoiceRegenerate           // r — call Claude again
	ChoiceQuit                 // q — exit without committing
	ChoiceInlineEdit           // user typed a replacement message directly
)

func ParseChoice

func ParseChoice(input string) Choice

ParseChoice interprets a single line of user input into a Choice. Single-char inputs are mapped to menu choices. Multi-char inputs are treated as inline message replacements.

type FileEntry

type FileEntry struct {
	Path     string
	Label    string // single-char status: "M", "A", "D", "R", "?"
	Selected bool
}

FileEntry is a display item for the file selector.

type RunOpts

type RunOpts struct {
	InitialMessage  string
	StagedFiles     []string                     // files that will be committed
	RegenerateFn    func() (string, error)       // called when user picks 'r'
	EditFn          func(string) (string, error) // called when user picks 'e'
	CommitFn        func(string) error           // called when user picks 'a'
	CommitAndPushFn func(string) error           // called when user picks 'A'
}

RunOpts holds the dependencies for the UI loop.

Jump to

Keyboard shortcuts

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