options

package
v0.0.0-...-553a8f7 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2019 License: Unlicense Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const Separator = '.'

Variables

This section is empty.

Functions

func MarshalMapValue

func MarshalMapValue(m reflect.Value, sep1, sep2 string) (s string, err error)

func MarshalSliceValue

func MarshalSliceValue(slice reflect.Value, sep string) (s string, err error)

func UnmarshalMap

func UnmarshalMap(src, sep1, sep2 string, ptrToMap interface{}) (err error)

func UnmarshalSlice

func UnmarshalSlice(src, sep string, ptrToSlice interface{}) (err error)

Types

type Option

type Option struct {
	Tags
	Name     string
	Var      reflect.Value
	DefValue string
}

func (Option) Apply

func (opt Option) Apply(val *string) (err error)

func (Option) Help

func (opt Option) Help() string

func (Option) String

func (opt Option) String() string

func (Option) ValueString

func (opt Option) ValueString() string

func (Option) ValueType

func (opt Option) ValueType() string

type Options

type Options []Option

Options is always sorted

func Reflect

func Reflect(o interface{}) (opts Options, err error)

Reflect structure/map

func (Options) Apply

func (opts Options) Apply(args []string, handleNotFound func(a string) bool) (natuals []string, err error)

Apply args into opts

func (Options) ApplyLoose

func (opts Options) ApplyLoose(args []string) (natuals []string, err error)

func (Options) ApplyStrict

func (opts Options) ApplyStrict(args []string) (natuals []string, err error)

func (Options) Filter

func (opts Options) Filter(f func(Option) bool) Options

func (Options) Get

func (opts Options) Get(name string) *Option

func (Options) Help

func (opts Options) Help() string

func (Options) PrintHelp

func (opts Options) PrintHelp(w io.Writer)

func (*Options) Reflect

func (opts *Options) Reflect(o interface{}, name string, tags *Tags) (err error)

func (*Options) ReflectValue

func (opts *Options) ReflectValue(v reflect.Value, name string, tags Tags) (err error)

func (Options) String

func (opts Options) String() string

type Tags

type Tags struct {
	Override  string
	Default   string // default value
	Usage     string
	Sensitive bool
	Inline    bool
	CfgFile   bool // -config=/etc/my.cfg
	Multi     bool // -load a -load b -load c

	AsString   bool
	Sep1, Sep2 string
	// contains filtered or unexported fields
}

Directories

Path Synopsis
Package arguments parse -key=value style command line arguments for package github.com/toy80/utils/options
Package arguments parse -key=value style command line arguments for package github.com/toy80/utils/options

Jump to

Keyboard shortcuts

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