flag

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(name string) bool

Bool parses bool flag of the flagset.

func BoolE

func BoolE(name string) (bool, error)

BoolE parses bool flag of the flagset with error returned.

func Float64

func Float64(name string) float64

Float64 parses int flag of the flagset.

func Float64E

func Float64E(name string) (float64, error)

Float64E parses int flag of the flagset with error returned.

func Int

func Int(name string) int64

Int parses int flag of the flagset.

func IntE

func IntE(name string) (int64, error)

IntE parses int flag of the flagset with error returned.

func Parse

func Parse() error

Parse parses the flagset.

func Register

func Register(fs ...Flag)

Register ...

func String

func String(name string) string

String parses string flag of the flagset.

func StringE

func StringE(name string) (string, error)

StringE parses string flag of the flagset with error returned.

func Uint

func Uint(name string) uint64

Uint parses int flag of the flagset.

func UintE

func UintE(name string) (uint64, error)

UintE parses int flag of the flagset with error returned.

func With

func With(fs ...Flag)

With adds flags to the flagset.

Types

type BoolFlag

type BoolFlag struct {
	Name     string
	Usage    string
	EnvVar   string
	Default  bool
	Variable *bool
	Action   func(string, *FlagSet)
}

BoolFlag is a bool flag implements of Flag interface.

func (*BoolFlag) Apply

func (f *BoolFlag) Apply(set *FlagSet)

Apply implements of Flag Apply function.

type Flag

type Flag interface {
	Apply(*FlagSet)
}

Flag defines application flag.

type FlagSet

type FlagSet struct {
	*flag.FlagSet
	// contains filtered or unexported fields
}

FlagSet wraps a set of Flags.

func (*FlagSet) Bool

func (fs *FlagSet) Bool(name string) bool

Bool parses bool flag of provided flagset.

func (*FlagSet) BoolE

func (fs *FlagSet) BoolE(name string) (bool, error)

BoolE parses bool flag of provided flagset with error returned.

func (*FlagSet) Float64

func (fs *FlagSet) Float64(name string) float64

Float64 parses int flag of provided flagset.

func (*FlagSet) Float64E

func (fs *FlagSet) Float64E(name string) (float64, error)

Float64E parses int flag of provided flagset with error returned.

func (*FlagSet) Int

func (fs *FlagSet) Int(name string) int64

Int parses int flag of provided flagset.

func (*FlagSet) IntE

func (fs *FlagSet) IntE(name string) (int64, error)

IntE parses int flag of provided flagset with error returned.

func (*FlagSet) Lookup

func (fs *FlagSet) Lookup(name string) *flag.Flag

Lookup lookup flag value by name priority: flag > default > env

func (*FlagSet) Parse

func (fs *FlagSet) Parse() error

Parse parses provided flagset.

func (*FlagSet) Register

func (fs *FlagSet) Register(flags ...Flag)

Register ...

func (*FlagSet) String

func (fs *FlagSet) String(name string) string

String parses string flag of provided flagset.

func (*FlagSet) StringE

func (fs *FlagSet) StringE(name string) (string, error)

StringE parses string flag of provided flagset with error returned.

func (*FlagSet) Uint

func (fs *FlagSet) Uint(name string) uint64

Uint parses int flag of provided flagset.

func (*FlagSet) UintE

func (fs *FlagSet) UintE(name string) (uint64, error)

UintE parses int flag of provided flagset with error returned.

func (*FlagSet) With

func (fs *FlagSet) With(flags ...Flag)

With adds flags to provided flagset.

type Float64Flag

type Float64Flag struct {
	Name     string
	Usage    string
	Default  float64
	Variable *float64
	Action   func(string, *FlagSet)
}

Float64Flag is a float flag implements of Flag interface.

func (*Float64Flag) Apply

func (f *Float64Flag) Apply(set *FlagSet)

Apply implements of Flag Apply function.

type IntFlag

type IntFlag struct {
	Name     string
	Usage    string
	Default  int
	Variable *int
	Action   func(string, *FlagSet)
}

IntFlag is an int flag implements of Flag interface.

func (*IntFlag) Apply

func (f *IntFlag) Apply(set *FlagSet)

Apply implements of Flag Apply function.

type StringFlag

type StringFlag struct {
	Name     string
	Usage    string
	EnvVar   string
	Default  string
	Variable *string
	// Action hooked after call fs.Parse()
	Action func(string, *FlagSet)
}

StringFlag is a string flag implements of Flag interface.

func (*StringFlag) Apply

func (f *StringFlag) Apply(set *FlagSet)

Apply implements of Flag Apply function.

type UintFlag

type UintFlag struct {
	Name     string
	Usage    string
	Default  uint
	Variable *uint
	Action   func(string, *FlagSet)
}

UintFlag is an uint flag implements of Flag interface.

func (*UintFlag) Apply

func (f *UintFlag) Apply(set *FlagSet)

Apply implements of Flag Apply function.

Jump to

Keyboard shortcuts

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