Documentation ¶
Overview ¶
Package interact provides implementations for some basic interaction that aims to make cli program a bit more pretty and let it easy to use.
This package will be splitted to a standalone repository in the future.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewToPreviouswithErr ¶
NewToPreviouswithErr warps error to ToPrevious.
func ScanInputAndCheck ¶
func ScanInputAndCheck() int
ScanInputAndCheck scans user input with check.
It returns -1 if input is not a number or is less than 0.
If nothing is input, return -2
Types ¶
type Choice ¶
Choice defines the basic abilities of Choice node.
This interface might be extended in the future.
type ChoiceHanlder ¶
type ChoiceHanlder func() (func(), error)
ChoiceHanlder defines function signature of a vaild choice function.
type Choose ¶
type Choose struct { Title string Choices []Choice Loop bool ToPreviousChooseDesc string // TODO ToNextPageDesc *Choice // TODO ToPreviousPageDesc *Choice }
Choose defines essential fields to let this interaction work.
func (*Choose) ToClosure ¶
func (c *Choose) ToClosure() ChoiceHanlder
ToClosure warps the Choose interaction to a ChoiceHanlder. It can be used to create a nesting choose interaction.
type DefaultChoice ¶
type DefaultChoice struct { Description string Function ChoiceHanlder }
DefaultChoice implements Choice interface with essential fields.
type ToPrevious ¶
type ToPrevious struct {
Err error
}
ToPrevious implements error interface that let app step out current choose loop.
func (*ToPrevious) Error ¶
func (e *ToPrevious) Error() string