Documentation ¶
Overview ¶
Package flagvalue provides flag.Value implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileSwitch ¶
type FileSwitch string
FileSwitch is a flag that accepts both "-x" and "-x=value", If a value is specified, it opens a file with that name. Otherwise, it uses a provided fallback writer.
func (*FileSwitch) Bool ¶
func (fs *FileSwitch) Bool() bool
Bool reports whether this flag was set with any value.
func (*FileSwitch) Create ¶
Create creates the file specified for this flag, and returns an io.Writer to it and a function to close it.
This has three possible behaviors:
- the flag wasn't passed in: returns an io.Discard
- the flag was passed without a value: returns the provided fallback
- the flag was passed with a value: opens the file and returns it
func (*FileSwitch) Get ¶
func (fs *FileSwitch) Get() any
Get returns the path stored in the writer or '-' if no value was specified.
func (*FileSwitch) IsBoolFlag ¶
func (*FileSwitch) IsBoolFlag() bool
IsBoolFlag marks this as a flag that doesn't require a value.
func (*FileSwitch) Set ¶
func (fs *FileSwitch) Set(v string) error
Set receives the value for this flag.
func (*FileSwitch) String ¶
func (fs *FileSwitch) String() string
String returns the path stored in the writer or '-' if no value was specified.
type List ¶
List is a generic flag.Getter that accepts zero or more instances of the same flag and combines them into a list.
func ListOf ¶
ListOf wraps a slice of flag.Getter objects to accept zero or more instances of that flag.
flag.Var(flagvalue.ListOf(&items), "item", ...)