Documentation ¶
Overview ¶
Package flags implements command-line flag parsing.
Index ¶
- func IsSet(fs *flag.FlagSet, name string) bool
- func SetBindAddrFromAddr(fs *flag.FlagSet, bindAddrFlagName, addrFlagName string)
- func SetFlagsFromEnv(fs *flag.FlagSet) error
- func URLsFromFlags(fs *flag.FlagSet, urlsFlagName string, addrFlagName string, ...) ([]url.URL, error)
- type DeprecatedFlag
- type IPAddressPort
- type IgnoredFlag
- type StringsFlag
- type URLsValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetBindAddrFromAddr ¶ added in v2.0.1
SetBindAddrFromAddr sets the value of bindAddr flag from the value of addr flag. Both flags' Value must be of type IPAddressPort. If the bindAddr flag is set and the addr flag is unset, it will set bindAddr to [::]:port of addr. Otherwise, it keeps the original values.
func SetFlagsFromEnv ¶
SetFlagsFromEnv parses all registered flags in the given flagset, and if they are not already set it attempts to set their values from environment variables. Environment variables take the name of the flag but are UPPERCASE, have the prefix "ETCD_", and any dashes are replaced by underscores - for example: some-flag => ETCD_SOME_FLAG
func URLsFromFlags ¶
func URLsFromFlags(fs *flag.FlagSet, urlsFlagName string, addrFlagName string, tlsInfo transport.TLSInfo) ([]url.URL, error)
URLsFromFlags decides what URLs should be using two different flags as datasources. The first flag's Value must be of type URLs, while the second must be of type IPAddressPort. If both of these flags are set, an error will be returned. If only the first flag is set, the underlying url.URL objects will be returned unmodified. If the second flag happens to be set, the underlying IPAddressPort will be converted to a url.URL and returned. The Scheme of the returned url.URL will be http unless the provided TLSInfo object is non-empty. If neither of the flags have been explicitly set, the default value of the first flag will be returned unmodified.
Types ¶
type DeprecatedFlag ¶
type DeprecatedFlag struct {
Name string
}
DeprecatedFlag encapsulates a flag that may have been previously valid but is now deprecated. If a DeprecatedFlag is set, an error occurs.
func (*DeprecatedFlag) Set ¶
func (f *DeprecatedFlag) Set(_ string) error
func (*DeprecatedFlag) String ¶
func (f *DeprecatedFlag) String() string
type IPAddressPort ¶
IPAddressPort implements the flag.Value interface. The argument is validated as "ip:port".
func (*IPAddressPort) Set ¶
func (a *IPAddressPort) Set(arg string) error
func (*IPAddressPort) String ¶
func (a *IPAddressPort) String() string
type IgnoredFlag ¶
type IgnoredFlag struct {
Name string
}
IgnoredFlag encapsulates a flag that may have been previously valid but is now ignored. If an IgnoredFlag is set, a warning is printed and operation continues.
func (*IgnoredFlag) IsBoolFlag ¶
func (f *IgnoredFlag) IsBoolFlag() bool
IsBoolFlag is defined to allow the flag to be defined without an argument
func (*IgnoredFlag) Set ¶
func (f *IgnoredFlag) Set(s string) error
func (*IgnoredFlag) String ¶
func (f *IgnoredFlag) String() string
type StringsFlag ¶
type StringsFlag struct { Values []string // contains filtered or unexported fields }
StringsFlag implements the flag.Value interface.
func NewStringsFlag ¶
func NewStringsFlag(valids ...string) *StringsFlag
NewStringsFlag creates a new string flag for which any one of the given strings is a valid value, and any other value is an error.
func (*StringsFlag) Set ¶
func (ss *StringsFlag) Set(s string) error
Set verifies the argument to be a valid member of the allowed values before setting the underlying flag value.
func (*StringsFlag) String ¶
func (ss *StringsFlag) String() string
String returns the set value (if any) of the StringsFlag
type URLsValue ¶
func NewURLsValue ¶
func (*URLsValue) Set ¶
Set parses a command line set of URLs formatted like: http://127.0.0.1:2380,http://10.1.1.2:80