Documentation ¶
Overview ¶
Package ask A golang library to ask user for typed answers, passwords and stuff
Index ¶
- Constants
- Variables
- func Bool() (*bool, error)
- func Float32() (*float32, error)
- func Float64() (*float64, error)
- func Int() (*int, error)
- func Int16() (*int16, error)
- func Int32() (*int32, error)
- func Int64() (*int64, error)
- func Int8() (*int8, error)
- func Interface(t VarType) (interface{}, error)
- func String() (*string, error)
- func Uint() (*uint, error)
- func Uint16() (*uint16, error)
- func Uint32() (*uint32, error)
- func Uint64() (*uint64, error)
- func Uint8() (*uint8, error)
- func YesNo() (*bool, error)
- type Collector
- type Doer
- func BoolVar(v *bool) Doer
- func Float32Var(v *float32) Doer
- func Float64Var(v *float64) Doer
- func Int16Var(v *int16) Doer
- func Int32Var(v *int32) Doer
- func Int64Var(v *int64) Doer
- func Int8Var(v *int8) Doer
- func IntVar(v *int) Doer
- func StringVar(v *string) Doer
- func Uint16Var(v *uint16) Doer
- func Uint32Var(v *uint32) Doer
- func Uint64Var(v *uint64) Doer
- func Uint8Var(v *uint8) Doer
- func UintVar(v *uint) Doer
- func YesNoVar(v *bool) Doer
- type ParseFunc
- type Prototype
- type Service
- func Before(v func() error) *Service
- func BeforeEach(v func(int) error) *Service
- func Column(v int) *Service
- func Default(v string) *Service
- func Enum(v []string) *Service
- func Envar(v string) *Service
- func Hidden(v bool) *Service
- func Limit(v int) *Service
- func Matcher(v *regexp.Regexp) *Service
- func Message(v string) *Service
- func Optional(v bool) *Service
- func Reader(v io.Reader) *Service
- func Validation(v func(string) error) *Service
- func Writer(v io.Writer) *Service
- func (s *Service) Ask(unmarshaler encoding.TextUnmarshaler) error
- func (s *Service) AskParseFunc(parse ParseFunc) error
- func (s *Service) AskUnmarshalFunc(unmarshal UnmarshalFunc) error
- func (s Service) Before(v func() error) *Service
- func (s Service) BeforeEach(v func(int) error) *Service
- func (s Service) Bool() (*bool, error)
- func (s Service) BoolVar(v *bool) Doer
- func (s Service) Column(v int) *Service
- func (s Service) Default(v string) *Service
- func (s Service) Enum(v []string) *Service
- func (s Service) Envar(v string) *Service
- func (s Service) Float32() (*float32, error)
- func (s Service) Float32Var(v *float32) Doer
- func (s Service) Float64() (*float64, error)
- func (s Service) Float64Var(v *float64) Doer
- func (s Service) Hidden(v bool) *Service
- func (s Service) Int() (*int, error)
- func (s Service) Int16() (*int16, error)
- func (s Service) Int16Var(v *int16) Doer
- func (s Service) Int32() (*int32, error)
- func (s Service) Int32Var(v *int32) Doer
- func (s Service) Int64() (*int64, error)
- func (s Service) Int64Var(v *int64) Doer
- func (s Service) Int8() (*int8, error)
- func (s Service) Int8Var(v *int8) Doer
- func (s Service) IntVar(v *int) Doer
- func (s Service) Interface(t VarType) (interface{}, error)
- func (s Service) Limit(v int) *Service
- func (s Service) Matcher(v *regexp.Regexp) *Service
- func (s Service) Message(v string) *Service
- func (s Service) Optional(v bool) *Service
- func (s Service) Reader(v io.Reader) *Service
- func (s Service) String() (*string, error)
- func (s Service) StringVar(v *string) Doer
- func (s Service) Uint() (*uint, error)
- func (s Service) Uint16() (*uint16, error)
- func (s Service) Uint16Var(v *uint16) Doer
- func (s Service) Uint32() (*uint32, error)
- func (s Service) Uint32Var(v *uint32) Doer
- func (s Service) Uint64() (*uint64, error)
- func (s Service) Uint64Var(v *uint64) Doer
- func (s Service) Uint8() (*uint8, error)
- func (s Service) Uint8Var(v *uint8) Doer
- func (s Service) UintVar(v *uint) Doer
- func (s Service) Validation(v func(string) error) *Service
- func (s *Service) Var(parse encoding.TextUnmarshaler) Doer
- func (s Service) Writer(v io.Writer) *Service
- func (s Service) YesNo() (*bool, error)
- func (s Service) YesNoVar(v *bool) Doer
- type UnmarshalFunc
- type VarType
Constants ¶
const ( // VarTypeString indicates the string VarTypeString = VarType("string") // VarTypeBool indicates the bool VarTypeBool = VarType("bool") // VarTypeYesNo indicates the bool VarTypeYesNo = VarType("yesNo") // VarTypeUint indicates the uint VarTypeUint = VarType("uint") // VarTypeUint8 indicates the uint8 VarTypeUint8 = VarType("uint8") // VarTypeUint16 indicates the uint16 VarTypeUint16 = VarType("uint16") // VarTypeUint32 indicates the uint32 VarTypeUint32 = VarType("uint32") // VarTypeUint64 indicates the uint64 VarTypeUint64 = VarType("uint64") // VarTypeInt indicates the int VarTypeInt = VarType("int") // VarTypeInt8 indicates the int8 VarTypeInt8 = VarType("int8") // VarTypeInt16 indicates the int16 VarTypeInt16 = VarType("int16") // VarTypeInt32 indicates the int32 VarTypeInt32 = VarType("int32") // VarTypeInt64 indicates the int64 VarTypeInt64 = VarType("int64") // VarTypeFloat32 indicates the float32 VarTypeFloat32 = VarType("float32") // VarTypeFloat64 indicates the float64 VarTypeFloat64 = VarType("float64") )
Variables ¶
var ErrSkip = errors.New("skip")
ErrSkip will skip to ask a value.
Functions ¶
Types ¶
type Doer ¶
type Doer interface {
Do() error
}
Doer will do.
func Float32Var ¶
Float32Var sets a float32 variable, "v" to accept user input
func Float64Var ¶
Float64Var sets a float64 variable, "v" to accept user input
type ParseFunc ¶ added in v0.0.5
func (ParseFunc) UnmarshalText ¶ added in v0.0.5
type Prototype ¶
type Prototype struct { Hidden bool Default string Envar string Validation func(string) error Matcher *regexp.Regexp Enum []string Column int Optional bool Limit int Reader io.Reader Writer io.Writer Message string Before func() error BeforeEach func(int) error }
Prototype gives handler some options
type Service ¶
type Service struct {
Prototype
}
Service is the handler to ask values.
func BeforeEach ¶
BeforeEach makes new Service with new BeforeEach option
func Validation ¶
Validation makes new Service with new Validation option
func (*Service) Ask ¶
func (s *Service) Ask(unmarshaler encoding.TextUnmarshaler) error
Ask will get a value from input and pass it to encoding.TextUnmarshaler.
func (*Service) AskParseFunc ¶ added in v0.0.5
AskParseFunc will get a value from input and pass it to parser func.
func (*Service) AskUnmarshalFunc ¶ added in v0.0.5
func (s *Service) AskUnmarshalFunc(unmarshal UnmarshalFunc) error
AskFunc will get a value from input and pass it to unmarshal func.
func (Service) BeforeEach ¶
BeforeEach makes new Service with new BeforeEach option
func (Service) Float32Var ¶
Float32Var sets a float32 variable, "v" to accept user input
func (Service) Float64Var ¶
Float64Var sets a float64 variable, "v" to accept user input
func (Service) Validation ¶
Validation makes new Service with new Validation option
func (*Service) Var ¶
func (s *Service) Var(parse encoding.TextUnmarshaler) Doer
Var sets encoding.TextUnmarshaler.
type UnmarshalFunc ¶ added in v0.0.5
func (UnmarshalFunc) UnmarshalText ¶ added in v0.0.5
func (f UnmarshalFunc) UnmarshalText(raw []byte) error