Documentation ¶
Overview ¶
prompts offers several configurable, ituitive and intractive CLI components including inputs, selectbox, radio box and alerts formatter, just to name a few
Index ¶
- func Alert(label string, color string, m string)
- func ConfirmBox(label string, def bool) (bool, error)
- func Error(m string)
- func ErrorMessage(m string)
- func Info(m string)
- func InfoMessage(m string)
- func InputBox(options InputOptions) (string, error)
- func Message(m string, color string)
- func RadioBox(label string, choices []string) (int, error)
- func SelectBox(label string, choices []string) ([]int, error)
- func Success(m string)
- func SuccessMessage(m string)
- func Warning(m string)
- func WarningMessage(m string)
- type InputOptions
- type SelectOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Alert ¶
Prints the alert "m" labeled by "label" with the specified color
example :
prompts.Alert("WARNING", "#fca311", "hello world")
func ConfirmBox ¶
prompt the user for confirmation , it returns a boolean
example :
const DEFAULT = true prompts.ConfirmBox("are you sure ?", DEFAULT)
func Error ¶
func Error(m string)
Prints the message "m" using the "ERROR" theme for styling. Perfect for short messages
func ErrorMessage ¶
func ErrorMessage(m string)
Prints the message "m" using the "ERROR" theme for styling. Perfect for long messages
func Info ¶
func Info(m string)
Prints the message "m" using the "INFO" theme for styling. Perfect for short messages
func InfoMessage ¶
func InfoMessage(m string)
Prints the message "m" using the "INFO" theme for styling. Perfect for long messages
func InputBox ¶
func InputBox(options InputOptions) (string, error)
prompt user to fill an input, it returns the user input string
example :
prompts.InputBox(prompts.InputOptions{ Secure: false, // hides the user input, very common for passwords Label: "what is your name?", Placeholder: "what is your name", Required: true, Validator: func(value string) error { // will be called when user submit, and returned error will be displayed to the user below the input if len(value) < 3 { return fmt.Errorf("minimum len is 3") } return nil }, })
func Message ¶
Prints the message "m" labeled by "label" with the specified color
example :
prompts.Message("hello world", "#fca311")
func RadioBox ¶
prompt user to choose one of several choices , and return the checked indexe
example :
prompts.RadioBox("you are intersted at ", []string{"gaming", "coding"})
func SelectBox ¶
prompt user to select between choices , and return the selected indexes
example :
prompts.SelectBox("you are intersted at ", []string{"gaming", "coding"})
func SuccessMessage ¶
func SuccessMessage(m string)
Prints the message "m" using the "SUCCESS" theme for styling. Perfect for long messages
func Warning ¶
func Warning(m string)
Prints the message "m" using the "WARNING" theme for styling. Perfect for short messages
func WarningMessage ¶
func WarningMessage(m string)
Prints the message "m" using the "WARNING" theme for styling. Perfect for long messages