package flags
import "go.etcd.io/etcd/pkg/v3/flags"
Package flags implements command-line flag parsing.
Index ¶
- func FlagToEnv(prefix, name string) string
- func IsSet(fs *flag.FlagSet, name string) bool
- func NewUint32Value(v uint32) *uint32Value
- func SetFlagsFromEnv(lg *zap.Logger, prefix string, fs *flag.FlagSet) error
- func SetPflagsFromEnv(lg *zap.Logger, prefix string, fs *pflag.FlagSet) error
- func StringsFromFlag(fs *flag.FlagSet, flagName string) []string
- func URLsFromFlag(fs *flag.FlagSet, urlsFlagName string) []url.URL
- func Uint32FromFlag(fs *flag.FlagSet, name string) uint32
- func UniqueStringsFromFlag(fs *flag.FlagSet, flagName string) []string
- func UniqueStringsMapFromFlag(fs *flag.FlagSet, flagName string) map[string]struct{}
- func UniqueURLsFromFlag(fs *flag.FlagSet, urlsFlagName string) []url.URL
- func UniqueURLsMapFromFlag(fs *flag.FlagSet, urlsFlagName string) map[string]struct{}
- type IgnoredFlag
- func (f *IgnoredFlag) IsBoolFlag() bool
- func (f *IgnoredFlag) Set(s string) error
- func (f *IgnoredFlag) String() string
- type SelectiveStringValue
- func NewSelectiveStringValue(valids ...string) *SelectiveStringValue
- func (ss *SelectiveStringValue) Set(s string) error
- func (ss *SelectiveStringValue) String() string
- func (ss *SelectiveStringValue) Valids() []string
- type SelectiveStringsValue
- func NewSelectiveStringsValue(valids ...string) *SelectiveStringsValue
- func (ss *SelectiveStringsValue) Set(s string) error
- func (ss *SelectiveStringsValue) String() string
- func (ss *SelectiveStringsValue) Valids() []string
- type StringsValue
- func NewStringsValue(s string) (ss *StringsValue)
- func (ss *StringsValue) Set(s string) error
- func (ss *StringsValue) String() string
- type URLsValue
- func NewURLsValue(s string) *URLsValue
- func (us *URLsValue) Set(s string) error
- func (us *URLsValue) String() string
- type UniqueStringsValue
- func NewUniqueStringsValue(s string) (us *UniqueStringsValue)
- func (us *UniqueStringsValue) Set(s string) error
- func (us *UniqueStringsValue) String() string
- type UniqueURLs
Functions ¶
func FlagToEnv ¶
FlagToEnv converts flag string to upper-case environment variable key string.
func IsSet ¶
func NewUint32Value ¶
func NewUint32Value(v uint32) *uint32Value
NewUint32Value creates an uint32 instance with the provided value.
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 given prefix and any dashes are replaced by underscores - for example: some-flag => ETCD_SOME_FLAG
func SetPflagsFromEnv ¶
SetPflagsFromEnv is similar to SetFlagsFromEnv. However, the accepted flagset type is pflag.FlagSet and it does not do any logging.
func StringsFromFlag ¶
StringsFromFlag returns a string slice from the flag.
func URLsFromFlag ¶
URLsFromFlag returns a slices from url got from the flag.
func Uint32FromFlag ¶
Uint32FromFlag return the uint32 value of a flag with the given name
func UniqueStringsFromFlag ¶
UniqueStringsFromFlag returns a string slice from the flag.
func UniqueStringsMapFromFlag ¶
UniqueStringsMapFromFlag returns a map of strings from the flag.
func UniqueURLsFromFlag ¶
UniqueURLsFromFlag returns a slice from urls got from the flag.
func UniqueURLsMapFromFlag ¶
UniqueURLsMapFromFlag returns a map from url strings got from the flag.
Types ¶
type IgnoredFlag ¶
type IgnoredFlag struct { Name string // contains filtered or unexported fields }
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 SelectiveStringValue ¶
type SelectiveStringValue struct {
// contains filtered or unexported fields
}
SelectiveStringValue implements the flag.Value interface.
func NewSelectiveStringValue ¶
func NewSelectiveStringValue(valids ...string) *SelectiveStringValue
NewSelectiveStringValue creates a new string flag for which any one of the given strings is a valid value, and any other value is an error.
valids[0] will be default value. Caller must be sure len(valids) != 0 or it will panic.
func (*SelectiveStringValue) Set ¶
func (ss *SelectiveStringValue) Set(s string) error
Set verifies the argument to be a valid member of the allowed values before setting the underlying flag value.
func (*SelectiveStringValue) String ¶
func (ss *SelectiveStringValue) String() string
String returns the set value (if any) of the SelectiveStringValue
func (*SelectiveStringValue) Valids ¶
func (ss *SelectiveStringValue) Valids() []string
Valids returns the list of valid strings.
type SelectiveStringsValue ¶
type SelectiveStringsValue struct {
// contains filtered or unexported fields
}
SelectiveStringsValue implements the flag.Value interface.
func NewSelectiveStringsValue ¶
func NewSelectiveStringsValue(valids ...string) *SelectiveStringsValue
NewSelectiveStringsValue creates a new string slice flag for which any one of the given strings is a valid value, and any other value is an error.
func (*SelectiveStringsValue) Set ¶
func (ss *SelectiveStringsValue) Set(s string) error
Set verifies the argument to be a valid member of the allowed values before setting the underlying flag value.
func (*SelectiveStringsValue) String ¶
func (ss *SelectiveStringsValue) String() string
String returns the set value (if any) of the SelectiveStringsValue.
func (*SelectiveStringsValue) Valids ¶
func (ss *SelectiveStringsValue) Valids() []string
Valids returns the list of valid strings.
type StringsValue ¶
type StringsValue sort.StringSlice
StringsValue wraps "sort.StringSlice".
func NewStringsValue ¶
func NewStringsValue(s string) (ss *StringsValue)
NewStringsValue implements string slice as "flag.Value" interface. Given value is to be separated by comma.
func (*StringsValue) Set ¶
func (ss *StringsValue) Set(s string) error
Set parses a command line set of strings, separated by comma. Implements "flag.Value" interface.
func (*StringsValue) String ¶
func (ss *StringsValue) String() string
String implements "flag.Value" interface.
type URLsValue ¶
URLsValue wraps "types.URLs".
func NewURLsValue ¶
NewURLsValue implements "url.URL" slice as flag.Value interface. Given value is to be separated by comma.
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 Implements "flag.Value" interface.
func (*URLsValue) String ¶
String implements "flag.Value" interface.
type UniqueStringsValue ¶
type UniqueStringsValue struct { Values map[string]struct{} }
UniqueStringsValue wraps a list of unique strings. The values are set in order.
func NewUniqueStringsValue ¶
func NewUniqueStringsValue(s string) (us *UniqueStringsValue)
NewUniqueStringsValue implements string slice as "flag.Value" interface. Given value is to be separated by comma. The values are set in order.
func (*UniqueStringsValue) Set ¶
func (us *UniqueStringsValue) Set(s string) error
Set parses a command line set of strings, separated by comma. Implements "flag.Value" interface. The values are set in order.
func (*UniqueStringsValue) String ¶
func (us *UniqueStringsValue) String() string
String implements "flag.Value" interface.
type UniqueURLs ¶
type UniqueURLs struct { Values map[string]struct{} Allowed map[string]struct{} // contains filtered or unexported fields }
UniqueURLs contains unique URLs with non-URL exceptions.
func NewUniqueURLsWithExceptions ¶
func NewUniqueURLsWithExceptions(s string, exceptions ...string) *UniqueURLs
NewUniqueURLsWithExceptions implements "url.URL" slice as flag.Value interface. Given value is to be separated by comma.
func (*UniqueURLs) Set ¶
func (us *UniqueURLs) Set(s string) error
Set parses a command line set of URLs formatted like: http://127.0.0.1:2380,http://10.1.1.2:80 Implements "flag.Value" interface.
func (*UniqueURLs) String ¶
func (us *UniqueURLs) String() string
String implements "flag.Value" interface.
Source Files ¶
flag.go ignored.go selective_string.go strings.go uint32.go unique_strings.go unique_urls.go urls.go
- Version
- v3.5.18 (latest)
- Published
- Jan 24, 2025
- Platform
- linux/amd64
- Imports
- 11 packages
- Last checked
- 6 days ago –
Tools for package owners.