prompt

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Prompt

type Prompt struct {
	Command   string         // Where does it call when complete?
	Rest      string         // What is the 'rest' of the command
	Questions []*Question    // All questions so far
	State     map[string]any // Optional place to store state
}

func New

func New(command string, rest string) *Prompt

func (*Prompt) Ask

func (p *Prompt) Ask(question string, responseOptions []string, defaultOption ...string) *Question

Returns the next pending question.

func (*Prompt) GetNextQuestion

func (p *Prompt) GetNextQuestion() *Question

Returns the next pending question.

func (*Prompt) Recall

func (p *Prompt) Recall(name string) (any, bool)

func (*Prompt) Store

func (p *Prompt) Store(name string, val any)

type Question

type Question struct {
	Question        string   // What's the prompt?
	Options         []string // What options (if any) are available? None = freeform
	DefaultResponse string   // What is the default response?
	Response        string   // What was the response last submitted
	Done            bool     // Was it seen and responded to?
	Flags           int      // Mask reply etc
}

func (*Question) Answer

func (q *Question) Answer(answer string)

If fewer than 2 choices provided, answer is what they enter. If they provide an empty string, and a default respnose is provided, answer is default.

func (*Question) RejectResponse

func (q *Question) RejectResponse()

func (*Question) Reset

func (q *Question) Reset()

func (*Question) String

func (q *Question) String() string

Jump to

Keyboard shortcuts

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