Documentation
¶
Overview ¶
Package interact collect some interactive methods for CLI
Index ¶
- Constants
- func AnswerIsYes(def ...bool) bool
- func Ask()
- func Checkbox()
- func Confirm(message string, defVal ...bool) bool
- func MultiSelect(message string)
- func NewAsk(q string)
- func QuickSelect(title string, options interface{}, defOpt string, allowQuit ...bool) string
- func ReadFirst(question string) (string, error)
- func ReadLine(question string) (string, error)
- type Interactive
- type Option
- type Question
- type Select
- type Value
Constants ¶
View Source
const ( // OK success exit code OK = 0 // ERR error exit code ERR = 2 )
Variables ¶
This section is empty.
Functions ¶
func AnswerIsYes ¶
AnswerIsYes check user inputted answer is right fmt.Print("are you OK?") ok := AnswerIsYes() ok := AnswerIsYes(true)
func MultiSelect ¶
func MultiSelect(message string)
func QuickSelect ¶
QuickSelect select one of the options, returns selected option value map options:
{
// option value => option name
'a' => 'chengdu',
'b' => 'beijing'
}
array options:
{
// only name, value will use index
'chengdu',
'beijing'
}
Types ¶
type Interactive ¶
type Interactive struct {
Name string
}
func New ¶
func New(name string) *Interactive
type Select ¶
type Select struct {
// Title message for select. e.g "Your city?"
Title string
// Options the options data for select. allow: []int,[]string,map[string]string
Options interface{}
// DefOpt default option when not input answer
DefOpt string
// NoQuit option. if is false, will display "quit" option
NoQuit bool
// contains filtered or unexported fields
}
Select definition
Click to show internal directories.
Click to hide internal directories.