Documentation
¶
Overview ¶
Package styledconsole helps to make your GUI tools user-friendly with methods to pretty-print text, lists, tables, user prompts, progress bars...
Index ¶
- func Ask(label string, validator func(string) bool) (string, error)
- func AskHidden(label string, validator func(string) bool) (string, error)
- func AskWithDefault(label string, defaultAnswer string, validator func(string) bool) (string, error)
- func Choice(label string, choices []string) (string, error)
- func ChoiceWithDefault(label string, choices []string, defaultAnswer int) (string, error)
- func Confirm(label string) (bool, error)
- func ConfirmWithDefault(label string, defaultAnswer bool) (bool, error)
- func Error(content string)
- func Listing(items []string)
- func NewLine()
- func NewLines(newLineCount int)
- func ProgressAdvance(stepCount int)
- func ProgressFinish()
- func ProgressStart(totalSteps int)
- func Section(title string)
- func Success(content string)
- func Table(headers []string, rows [][]string)
- func Text(content string)
- func Warning(content string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ask ¶
Ask prompts a question with the given label. A function can be given to ensure the validity of the response. To allow any response (even empty), put nil as validator.
func AskHidden ¶
Same as Ask() but the characters typed by the user are not printed in the output, in a linux-style password prompt.
func AskWithDefault ¶
func AskWithDefault(label string, defaultAnswer string, validator func(string) bool) (string, error)
Same as Ask() but if the user's answer is empty, the given defaultAnswer is chosen instead.
func Choice ¶
Choice prints a list of choices the user can choose between. The prompts adapts itself to the size of the terminal.
func ChoiceWithDefault ¶
ChoiceWithDefault is the same as Choice() but a specific answer index should be given to highlight by default.
func ConfirmWithDefault ¶
ConfirmWithDefault prompts a yes/no question, with a given answer by default if the user's answer is empty.
func Error ¶
func Error(content string)
Error displays the given string highlighted as an error message (with a red background and the Error label).
func ProgressAdvance ¶
func ProgressAdvance(stepCount int)
ProgressAdvance advances the current progress bar of a given stepCount. If there is no progressBar it does nothing
func ProgressFinish ¶
func ProgressFinish()
ProgressFinish finishes the current progress bar. If there is no progressBar it does nothing
func ProgressStart ¶
func ProgressStart(totalSteps int)
ProgressStart starts a progress bar of a given duration
func Section ¶
func Section(title string)
Section displays the given string as the title of some command section.
func Success ¶
func Success(content string)
Success displays the given string highlighted as a successful message (with a green background and an [OK] label).
func Table ¶
Table pretty-prints a table with headers. It does not support multiline cells or sytling.
Types ¶
This section is empty.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package styledprinter helps to do some pretty-printing of text in terminal using ANSI escape sequences
|
Package styledprinter helps to do some pretty-printing of text in terminal using ANSI escape sequences |