Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTerminate is a sentinel error an answer function can return to indicate // that the interview should terminate, and the tracked state should be // discarded rather than persisted or returned to the user. ErrTerminate = errors.New("interview terminated") )
Functions ¶
This section is empty.
Types ¶
type AcceptText ¶
AcceptText is a means of answering a question where the user can provide freeform text.
type Choice ¶
type Choice[T any] struct { // The Text of the choice to present to the user. Text string // Choose should update and return the given state in consideration of this // choice being selected by the user. It can also return the next question, // unless the line of questioning is concluded, in which case it should return // nil. Choose ChooseFunc[T] }
type ChooseFunc ¶
ChooseFunc is a function that can be used as the Choose method of a Choice.
func NewChooseFunc ¶
func NewChooseFunc[T any](next *Question[T]) ChooseFunc[T]
NewChooseFunc returns a function that can be used as the Choose method of a Choice. It simply returns the state unmodified and the given next question.
type MessageOnly ¶
MessageOnly is a means of answering a question where the user is presented with a message only, and where the only possible action is to proceed to the next question.
In other words, this effectively turns the Question into a message that the user must acknowledge before proceeding.
type MultipleChoice ¶
MultipleChoice is a means of answering a question where the user can choose an option (Choice) from a list.
type Question ¶
type Question[T any] struct { // The question to ask the user. Text string // The means of answering the question. The concrete type should be one of: // - AcceptText[T] // - MessageOnly[T] // - MultipleChoice[T] Answer any }
func NewMessage ¶
NewMessage returns a new "Question" that is only a message for the user to acknowledge. Once acknowledged, the user will proceed to the supplied next question, and the state will be passed through unmodified.
func NewTerminatingMessage ¶
NewTerminatingMessage returns a new "Question" that is only a message for the user to acknowledge. Once acknowledged, the interview should terminate.