input

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package input provides terminal input collection for interactive plan creation.

Index

Constants

View Source
const (
	ActionAccept = "accept"
	ActionRevise = "revise"
	ActionReject = "reject"
)

draft review action constants

Variables

This section is empty.

Functions

func AskYesNo added in v0.6.0

func AskYesNo(ctx context.Context, prompt string, stdin io.Reader, stdout io.Writer) bool

AskYesNo prompts with y/N and returns true for yes. defaults to no on EOF, empty input, context cancellation, or any read error.

func ReadLineWithContext added in v0.6.0

func ReadLineWithContext(ctx context.Context, reader *bufio.Reader) (string, error)

ReadLineWithContext reads a line from reader with context cancellation support. returns the line (including newline), error, or context error if canceled. this allows Ctrl+C (SIGINT) to interrupt blocking stdin reads.

Types

type Collector

type Collector interface {
	// AskQuestion presents a question with options and returns the selected answer.
	// Returns the selected option text or error if selection fails.
	AskQuestion(ctx context.Context, question string, options []string) (string, error)

	// AskDraftReview presents a plan draft for review with Accept/Revise/Reject options.
	// Returns the selected action ("accept", "revise", or "reject") and feedback text (empty for accept/reject).
	AskDraftReview(ctx context.Context, question string, planContent string) (action string, feedback string, err error)
}

Collector provides interactive input collection for plan creation.

type TerminalCollector

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

TerminalCollector implements Collector using fzf (if available) or numbered selection fallback.

func NewTerminalCollector

func NewTerminalCollector(noColor bool) *TerminalCollector

NewTerminalCollector creates a new TerminalCollector with specified options.

func (*TerminalCollector) AskDraftReview added in v0.6.0

func (c *TerminalCollector) AskDraftReview(ctx context.Context, question, planContent string) (string, string, error)

AskDraftReview presents a plan draft for review with Accept/Revise/Reject options. Shows the rendered plan content, then prompts for action selection. If Revise is selected, prompts for feedback text. Returns action ("accept", "revise", "reject") and feedback (empty for accept/reject).

func (*TerminalCollector) AskQuestion

func (c *TerminalCollector) AskQuestion(ctx context.Context, question string, options []string) (string, error)

AskQuestion presents options using fzf if available, otherwise falls back to numbered selection.

Jump to

Keyboard shortcuts

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