Documentation ¶
Index ¶
- Constants
- Variables
- func BoxPrintln(a ...interface{})
- func GoENERGY()
- func NewCancelationSignal(interruptFunc func()) (func(), func())
- func Println(a ...interface{})
- func TextInputWith(text, delimiter string) string
- func WithBoolean(b []bool) bool
- type InteractiveMultiselectPrinter
- func (p *InteractiveMultiselectPrinter) CheckmarkANSI()
- func (p *InteractiveMultiselectPrinter) Show(text ...string) ([]string, error)
- func (p InteractiveMultiselectPrinter) WithCheckmark(checkmark *pterm.Checkmark) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithDefaultOptions(options []string) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithDefaultText(text string) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithFilter(b ...bool) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithKeyConfirm(keyConfirm keys.KeyCode) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithKeySelect(keySelect keys.KeyCode) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithMaxHeight(maxHeight int) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithOptions(options []string) *InteractiveMultiselectPrinter
- type InteractiveSelectPrinter
- func (p *InteractiveSelectPrinter) CheckmarkANSI()
- func (p *InteractiveSelectPrinter) Show(text ...string) (string, error)
- func (p InteractiveSelectPrinter) WithDefaultOption(option string) *InteractiveSelectPrinter
- func (p InteractiveSelectPrinter) WithDefaultText(text string) *InteractiveSelectPrinter
- func (p InteractiveSelectPrinter) WithFilter(b ...bool) *InteractiveSelectPrinter
- func (p InteractiveSelectPrinter) WithMaxHeight(maxHeight int) *InteractiveSelectPrinter
- func (p InteractiveSelectPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveSelectPrinter
- func (p InteractiveSelectPrinter) WithOptions(options []string) *InteractiveSelectPrinter
- type Termout
Constants ¶
const ( Build = 1 Major = 0 Minor = 5 )
Variables ¶
var ( // DefaultInteractiveMultiselect is the default InteractiveMultiselect printer. DefaultInteractiveMultiselect = InteractiveMultiselectPrinter{ TextStyle: &pterm.ThemeDefault.PrimaryStyle, DefaultText: "Please select your options", Options: []string{}, OptionStyle: &pterm.ThemeDefault.DefaultText, DefaultOptions: []string{}, MaxHeight: 5, Selector: ">", SelectorStyle: &pterm.ThemeDefault.SecondaryStyle, Filter: true, KeySelect: keys.Space, KeyConfirm: keys.Enter, Up: 'w', Down: 's', Left: 'a', Right: 'd', Checkmark: &pterm.ThemeDefault.Checkmark, } )
var ( // DefaultInteractiveSelect is the default InteractiveSelect printer. DefaultInteractiveSelect = InteractiveSelectPrinter{ TextStyle: &pterm.ThemeDefault.PrimaryStyle, DefaultText: "Please select an option", Options: []string{}, OptionStyle: &pterm.ThemeDefault.DefaultText, DefaultOption: "", MaxHeight: 5, Selector: ">", SelectorStyle: &pterm.ThemeDefault.SecondaryStyle, Filter: true, Up: 'w', Down: 's', } )
var IsWindows10 = true
var Logger *pterm.Logger
var Section *pterm.SectionPrinter
var TermOut = new(Termout)
Functions ¶
func BoxPrintln ¶
func BoxPrintln(a ...interface{})
func NewCancelationSignal ¶
func NewCancelationSignal(interruptFunc func()) (func(), func())
NewCancelationSignal for keeping track of a cancelation
func TextInputWith ¶
func WithBoolean ¶
WithBoolean helps an option setter (WithXXX(b ...bool) to return true, if no boolean is set, but false if it's explicitly set to false.
Types ¶
type InteractiveMultiselectPrinter ¶
type InteractiveMultiselectPrinter struct { DefaultText string TextStyle *pterm.Style Options []string OptionStyle *pterm.Style DefaultOptions []string MaxHeight int Selector string SelectorStyle *pterm.Style Filter bool Checkmark *pterm.Checkmark OnInterruptFunc func() // KeySelect is the select key. It cannot be keys.Space when Filter is enabled. KeySelect keys.KeyCode // KeyConfirm is the confirm key. It cannot be keys.Space when Filter is enabled. KeyConfirm keys.KeyCode // 自定义上下左右选择键 Up keys.KeyCode Down keys.KeyCode Left keys.KeyCode Right keys.KeyCode // contains filtered or unexported fields }
InteractiveMultiselectPrinter is a printer for interactive multiselect menus.
func (*InteractiveMultiselectPrinter) CheckmarkANSI ¶
func (p *InteractiveMultiselectPrinter) CheckmarkANSI()
func (*InteractiveMultiselectPrinter) Show ¶
func (p *InteractiveMultiselectPrinter) Show(text ...string) ([]string, error)
Show shows the interactive multiselect menu and returns the selected entry.
func (InteractiveMultiselectPrinter) WithCheckmark ¶
func (p InteractiveMultiselectPrinter) WithCheckmark(checkmark *pterm.Checkmark) *InteractiveMultiselectPrinter
WithCheckmark sets the checkmark
func (InteractiveMultiselectPrinter) WithDefaultOptions ¶
func (p InteractiveMultiselectPrinter) WithDefaultOptions(options []string) *InteractiveMultiselectPrinter
WithDefaultOptions sets the default options.
func (InteractiveMultiselectPrinter) WithDefaultText ¶
func (p InteractiveMultiselectPrinter) WithDefaultText(text string) *InteractiveMultiselectPrinter
WithDefaultText sets the default text.
func (InteractiveMultiselectPrinter) WithFilter ¶
func (p InteractiveMultiselectPrinter) WithFilter(b ...bool) *InteractiveMultiselectPrinter
WithFilter sets the Filter option
func (InteractiveMultiselectPrinter) WithKeyConfirm ¶
func (p InteractiveMultiselectPrinter) WithKeyConfirm(keyConfirm keys.KeyCode) *InteractiveMultiselectPrinter
WithKeyConfirm sets the confirm key It cannot be keys.Space when Filter is enabled.
func (InteractiveMultiselectPrinter) WithKeySelect ¶
func (p InteractiveMultiselectPrinter) WithKeySelect(keySelect keys.KeyCode) *InteractiveMultiselectPrinter
WithKeySelect sets the confirm key It cannot be keys.Space when Filter is enabled.
func (InteractiveMultiselectPrinter) WithMaxHeight ¶
func (p InteractiveMultiselectPrinter) WithMaxHeight(maxHeight int) *InteractiveMultiselectPrinter
WithMaxHeight sets the maximum height of the select menu.
func (InteractiveMultiselectPrinter) WithOnInterruptFunc ¶
func (p InteractiveMultiselectPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveMultiselectPrinter
OnInterrupt sets the function to execute on exit of the input reader
func (InteractiveMultiselectPrinter) WithOptions ¶
func (p InteractiveMultiselectPrinter) WithOptions(options []string) *InteractiveMultiselectPrinter
WithOptions sets the options.
type InteractiveSelectPrinter ¶
type InteractiveSelectPrinter struct { TextStyle *pterm.Style DefaultText string Options []string OptionStyle *pterm.Style DefaultOption string MaxHeight int Selector string SelectorStyle *pterm.Style OnInterruptFunc func() Filter bool // 自定义上下选择键 Up keys.KeyCode Down keys.KeyCode // contains filtered or unexported fields }
InteractiveSelectPrinter is a printer for interactive select menus.
func (*InteractiveSelectPrinter) CheckmarkANSI ¶
func (p *InteractiveSelectPrinter) CheckmarkANSI()
func (*InteractiveSelectPrinter) Show ¶
func (p *InteractiveSelectPrinter) Show(text ...string) (string, error)
Show shows the interactive select menu and returns the selected entry.
func (InteractiveSelectPrinter) WithDefaultOption ¶
func (p InteractiveSelectPrinter) WithDefaultOption(option string) *InteractiveSelectPrinter
WithDefaultOption sets the default options.
func (InteractiveSelectPrinter) WithDefaultText ¶
func (p InteractiveSelectPrinter) WithDefaultText(text string) *InteractiveSelectPrinter
WithDefaultText sets the default text.
func (InteractiveSelectPrinter) WithFilter ¶
func (p InteractiveSelectPrinter) WithFilter(b ...bool) *InteractiveSelectPrinter
WithFilter sets the Filter option
func (InteractiveSelectPrinter) WithMaxHeight ¶
func (p InteractiveSelectPrinter) WithMaxHeight(maxHeight int) *InteractiveSelectPrinter
WithMaxHeight sets the maximum height of the select menu.
func (InteractiveSelectPrinter) WithOnInterruptFunc ¶
func (p InteractiveSelectPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveSelectPrinter
OnInterrupt sets the function to execute on exit of the input reader
func (InteractiveSelectPrinter) WithOptions ¶
func (p InteractiveSelectPrinter) WithOptions(options []string) *InteractiveSelectPrinter
WithOptions sets the options.