Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCanceled = fmt.Errorf("operation canceled")
Functions ¶
func QuitScreen ¶
func QuitScreen() quitScreen
Types ¶
type App ¶
type App interface { Name() string Run(firstScreen Screen) error NewPassword(question string, hd func(string) Screen) Screen NewInput(question string, hd func(string) Screen) Screen NewMultiSelect(question string, choices []string, hd func(s []string) Screen) Screen NewOutput(message string, next func() Screen) Screen NewSelect(question string, choices []string, hd func(string) Screen) Screen NewError(message string) Screen }
type DateTime ¶
type DateTime string
the string is the format of the expected datetime (excel format)
type GUI ¶
type GUI interface { Input(msg string, prefilled string, hideText bool) (res string, back bool, err error) Select(msg string, items []string, selected string) (res string, back bool, err error) MultiSelect(msg string, items []string, preselected []string) (res []string, back bool, err error) Output(msg string) (back bool, err error) Error(msg string) SetApp(a AppExt) }
type Option ¶
type Option func(s *app)
func WithBackNavigation ¶
func WithBackNavigation() Option
func WithBreadcrumb ¶
func WithBreadcrumb() Option
func WithFooter ¶
func WithFooter() Option
func WithHeader ¶
func WithHeader() Option
type Screen ¶
type Screen interface { Name() string UUID() string SetOptions(opts ...ScreenOption) }
type ScreenOption ¶
type ScreenOption func(*screenConfig)
func OptionCharLimit ¶
func OptionCharLimit(n int) ScreenOption
func OptionName ¶
func OptionName(n string) ScreenOption
func OptionPrefilled ¶
func OptionPrefilled(val interface{}) ScreenOption
func OptionSetUUID ¶
func OptionSetUUID(s string) ScreenOption
func OptionValidator ¶
func OptionValidator(v Validator) ScreenOption
type Validator ¶
type Validator interface { // if the value is valid, nil is returned. otherwise we can use the error message Validate(v interface{}) error }
type ValidatorFunc ¶
type ValidatorFunc func(interface{}) error
var Any ValidatorFunc = func(v interface{}) error { return nil }
var Int ValidatorFunc = func(v interface{}) error { switch t := v.(type) { case int: case int8: case int16: case int32: case int64: case uint: case uint8: case uint16: case uint32: case uint64: case string: _, err := strconv.Atoi(t) if err != nil { return fmt.Errorf("'%s' is no integer", t) } default: return fmt.Errorf("%v is no integer", v) } return nil }
var NonEmpty ValidatorFunc = func(v interface{}) error { err := fmt.Errorf("%v is empty", v) switch vv := v.(type) { case string: if vv == "" { return err } case int: if vv == -1 { return err } case float32: if vv < 0.0 { return err } case float64: if vv < 0.0 { return err } default: if v == nil { return err } } return nil }
func (ValidatorFunc) Validate ¶
func (fn ValidatorFunc) Validate(v interface{}) error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.