optvar

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDataSourceIsNil = errors.New("data source is nil")
)

Functions

func MissingRequiredVar

func MissingRequiredVar(name string) error

func UnsupportedType

func UnsupportedType(kind reflect.Kind) error

Types

type BoolVar

type BoolVar struct {
	// contains filtered or unexported fields
}

func Bool

func Bool(name string, ptr *bool, dft bool) *BoolVar

func RequiredBool

func RequiredBool(name string, ptr *bool) *BoolVar

func (*BoolVar) Error

func (i *BoolVar) Error() error

func (*BoolVar) Get

func (i *BoolVar) Get() bool

func (*BoolVar) IsNil

func (i *BoolVar) IsNil() bool

func (*BoolVar) IsSet

func (i *BoolVar) IsSet() bool

func (*BoolVar) Name

func (i *BoolVar) Name() string

func (*BoolVar) Set

func (i *BoolVar) Set(s string) error

func (*BoolVar) Source

func (i *BoolVar) Source() string

type DataSource

type DataSource interface {
	Apply(Options) error
}

DataSource represents a data source which can apply to Options

func CommandLine

func CommandLine() DataSource

CommandLine creates DataSource from flag.CommandLine

func FlagSet

func FlagSet(flagSet *flag.FlagSet) DataSource

FlagSet creates DataSource from flag.FlagSet

func Form

func Form(values url.Values) DataSource

Form creates DataSource from url.Values

func FormString

func FormString(s string) (DataSource, error)

FormString creates DataSource from raw form string

func FromKV

func FromKV(kv KeyValueSource) DataSource

FromKV converts KeyValueSource to DataSource

func FromKV2

func FromKV2(kv KeyValueSource2) DataSource

FromKV2 converts KeyValueSource2 to DataSource

func Map

func Map(m map[string]string) DataSource

Map creates DataSource from string->string map

type Int16Var

type Int16Var struct {
	// contains filtered or unexported fields
}

func Int16

func Int16(name string, ptr *int16, dft int16) *Int16Var

func RequiredInt16

func RequiredInt16(name string, ptr *int16) *Int16Var

func (*Int16Var) Error

func (i *Int16Var) Error() error

func (*Int16Var) Get

func (i *Int16Var) Get() int16

func (*Int16Var) IsNil

func (i *Int16Var) IsNil() bool

func (*Int16Var) IsSet

func (i *Int16Var) IsSet() bool

func (*Int16Var) Name

func (i *Int16Var) Name() string

func (*Int16Var) Set

func (i *Int16Var) Set(s string) error

func (*Int16Var) Source

func (i *Int16Var) Source() string

type Int32Var

type Int32Var struct {
	// contains filtered or unexported fields
}

func Int32

func Int32(name string, ptr *int32, dft int32) *Int32Var

func RequiredInt32

func RequiredInt32(name string, ptr *int32) *Int32Var

func (*Int32Var) Error

func (i *Int32Var) Error() error

func (*Int32Var) Get

func (i *Int32Var) Get() int32

func (*Int32Var) IsNil

func (i *Int32Var) IsNil() bool

func (*Int32Var) IsSet

func (i *Int32Var) IsSet() bool

func (*Int32Var) Name

func (i *Int32Var) Name() string

func (*Int32Var) Set

func (i *Int32Var) Set(s string) error

func (*Int32Var) Source

func (i *Int32Var) Source() string

type Int64Var

type Int64Var struct {
	// contains filtered or unexported fields
}

func Int64

func Int64(name string, ptr *int64, dft int64) *Int64Var

func RequiredInt64

func RequiredInt64(name string, ptr *int64) *Int64Var

func (*Int64Var) Error

func (i *Int64Var) Error() error

func (*Int64Var) Get

func (i *Int64Var) Get() int64

func (*Int64Var) IsNil

func (i *Int64Var) IsNil() bool

func (*Int64Var) IsSet

func (i *Int64Var) IsSet() bool

func (*Int64Var) Name

func (i *Int64Var) Name() string

func (*Int64Var) Set

func (i *Int64Var) Set(s string) error

func (*Int64Var) Source

func (i *Int64Var) Source() string

type IntVar

type IntVar struct {
	// contains filtered or unexported fields
}

func Int

func Int(name string, ptr *int, dft int) *IntVar

func RequiredInt

func RequiredInt(name string, ptr *int) *IntVar

func (*IntVar) Error

func (i *IntVar) Error() error

func (*IntVar) Get

func (i *IntVar) Get() int

func (*IntVar) IsNil

func (i *IntVar) IsNil() bool

func (*IntVar) IsSet

func (i *IntVar) IsSet() bool

func (*IntVar) Name

func (i *IntVar) Name() string

func (*IntVar) Set

func (i *IntVar) Set(s string) error

func (*IntVar) Source

func (i *IntVar) Source() string

type KeyValueSource

type KeyValueSource interface {
	Get(string) string
}

type KeyValueSource2

type KeyValueSource2 interface {
	Get(string) (string, bool)
}

type MissingRequiredVarError

type MissingRequiredVarError string

func (MissingRequiredVarError) Error

func (e MissingRequiredVarError) Error() string

type Options

type Options interface {
	Name() string
	Groups() []Options
	Values() []Value
}

func Groups

func Groups(name string, groups ...Options) Options

Groups creates a `Options`: options

func Reflect

func Reflect(name string, v interface{}, tagName string) (Options, error)

func Values

func Values(name string, values ...Value) Options

Values creates a `Options`: group

type Source

type Source struct {
	Str string
	Err error
}

type StringVar

type StringVar struct {
	// contains filtered or unexported fields
}

func RequiredString

func RequiredString(name string, ptr *string) *StringVar

func String

func String(name string, ptr *string, dft string) *StringVar

func (*StringVar) Error

func (i *StringVar) Error() error

func (*StringVar) Get

func (i *StringVar) Get() string

func (*StringVar) IsNil

func (i *StringVar) IsNil() bool

func (*StringVar) IsSet

func (i *StringVar) IsSet() bool

func (*StringVar) Name

func (i *StringVar) Name() string

func (*StringVar) Set

func (i *StringVar) Set(s string) error

func (*StringVar) Source

func (i *StringVar) Source() string

type Uint16Var

type Uint16Var struct {
	// contains filtered or unexported fields
}

func RequiredUint16

func RequiredUint16(name string, ptr *uint16) *Uint16Var

func Uint16

func Uint16(name string, ptr *uint16, dft uint16) *Uint16Var

func (*Uint16Var) Error

func (i *Uint16Var) Error() error

func (*Uint16Var) Get

func (i *Uint16Var) Get() uint16

func (*Uint16Var) IsNil

func (i *Uint16Var) IsNil() bool

func (*Uint16Var) IsSet

func (i *Uint16Var) IsSet() bool

func (*Uint16Var) Name

func (i *Uint16Var) Name() string

func (*Uint16Var) Set

func (i *Uint16Var) Set(s string) error

func (*Uint16Var) Source

func (i *Uint16Var) Source() string

type Uint32Var

type Uint32Var struct {
	// contains filtered or unexported fields
}

func RequiredUint32

func RequiredUint32(name string, ptr *uint32) *Uint32Var

func Uint32

func Uint32(name string, ptr *uint32, dft uint32) *Uint32Var

func (*Uint32Var) Error

func (i *Uint32Var) Error() error

func (*Uint32Var) Get

func (i *Uint32Var) Get() uint32

func (*Uint32Var) IsNil

func (i *Uint32Var) IsNil() bool

func (*Uint32Var) IsSet

func (i *Uint32Var) IsSet() bool

func (*Uint32Var) Name

func (i *Uint32Var) Name() string

func (*Uint32Var) Set

func (i *Uint32Var) Set(s string) error

func (*Uint32Var) Source

func (i *Uint32Var) Source() string

type Uint64Var

type Uint64Var struct {
	// contains filtered or unexported fields
}

func RequiredUint64

func RequiredUint64(name string, ptr *uint64) *Uint64Var

func Uint64

func Uint64(name string, ptr *uint64, dft uint64) *Uint64Var

func (*Uint64Var) Error

func (i *Uint64Var) Error() error

func (*Uint64Var) Get

func (i *Uint64Var) Get() uint64

func (*Uint64Var) IsNil

func (i *Uint64Var) IsNil() bool

func (*Uint64Var) IsSet

func (i *Uint64Var) IsSet() bool

func (*Uint64Var) Name

func (i *Uint64Var) Name() string

func (*Uint64Var) Set

func (i *Uint64Var) Set(s string) error

func (*Uint64Var) Source

func (i *Uint64Var) Source() string

type UintVar

type UintVar struct {
	// contains filtered or unexported fields
}

func RequiredUint

func RequiredUint(name string, ptr *uint) *UintVar

func Uint

func Uint(name string, ptr *uint, dft uint) *UintVar

func (*UintVar) Error

func (i *UintVar) Error() error

func (*UintVar) Get

func (i *UintVar) Get() uint

func (*UintVar) IsNil

func (i *UintVar) IsNil() bool

func (*UintVar) IsSet

func (i *UintVar) IsSet() bool

func (*UintVar) Name

func (i *UintVar) Name() string

func (*UintVar) Set

func (i *UintVar) Set(s string) error

func (*UintVar) Source

func (i *UintVar) Source() string

type UnsupportedTypeErrror

type UnsupportedTypeErrror struct {
	// contains filtered or unexported fields
}

func (UnsupportedTypeErrror) Error

func (e UnsupportedTypeErrror) Error() string

type Value

type Value interface {
	Name() string
	Set(string) error
	IsNil() bool
	IsSet() bool
	Source() string
	Error() error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL