Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RepeatedStringMap ¶
RepeatedStringMap represents values for a CLI argument where key value pairs are populated by repeating the option. This has to be a distinct type because the parsing behavior is defined as a receiver method on the type
func (*RepeatedStringMap) Set ¶
func (m *RepeatedStringMap) Set(value string) error
func (*RepeatedStringMap) String ¶
func (m *RepeatedStringMap) String() string
func (*RepeatedStringMap) Value ¶
func (m *RepeatedStringMap) Value() map[string]string
type RepeatedStringMapFlag ¶
type RepeatedStringMapFlag struct {
Name string
Usage string
// EnvVarPrefix, when non-empty, identifies a family of environment variables
// that seed the flag's value. Every variable named "<EnvVarPrefix>_<KEY>" is
// turned into a "<key>=<value>" entry, where only the key is lowercased.
// For example, with prefix CADENCE_SETUP_OPTION the variable
// CADENCE_SETUP_OPTION_REPLICATION_FACTOR=1 yields "replication_factor=1".
// Values given on the command line are appended after the environment
// derived ones, so consumers see duplicate keys as a conflict.
EnvVarPrefix string
// contains filtered or unexported fields
}
RepeatedStringMapFlag is a cli.Flag for key/value pairs by repeating the option rather than parsing a single value into key/value pairs. For example, "--setup-option replication_factor=1 --setup-option cluster=dca" yields map[string]string{"replication_factor": "1", "cluster": "dca"}. The flag can also be seeded from environment variables with a common prefix, e.g. CADENCE_SETUP_OPTION_<KEY>=<VALUE>. See EnvVarPrefix. The only parsing logic is that the value is split on the first `=`, and may contain any other characters after that. Each Apply creates a fresh RepeatedStringMap to prevent cross-run accumulation when the flag is defined as a package-level var.
func (*RepeatedStringMapFlag) Apply ¶
func (f *RepeatedStringMapFlag) Apply(set *goflag.FlagSet) error
Apply registers a fresh RepeatedStringMap with the flag set on every call, preventing cross-run accumulation when the flag is a package-level var. When EnvVarPrefix is set, matching environment variables seed the slice.
func (*RepeatedStringMapFlag) IsSet ¶
func (f *RepeatedStringMapFlag) IsSet() bool
IsSet reports whether values were seeded from the environment. Values passed on the command line are detected by c.IsSet() via fs.Visit, which is the authoritative check for those.
func (*RepeatedStringMapFlag) IsVisible ¶
func (f *RepeatedStringMapFlag) IsVisible() bool
IsVisible makes the flag appear in --help output; urfave/cli hides any flag that does not implement cli.VisibleFlag.
func (*RepeatedStringMapFlag) Names ¶
func (f *RepeatedStringMapFlag) Names() []string
func (*RepeatedStringMapFlag) String ¶
func (f *RepeatedStringMapFlag) String() string
type StringMap ¶
func (*StringMap) Set ¶
Set resets the map before parsing. This is intentional: StringMap is used as a GenericFlag.Value on package-level vars; without a reset, values from a previous app.Run() call accumulate into the next parse. The reset also makes Set idempotent when urfave/cli's normalizeFlags copies the flag value to aliases via Set(String()) — see String() below.
func (*StringMap) String ¶
String returns the map in key1=v1,key2=v2 format so that it round-trips cleanly through Set. urfave/cli's normalizeFlags propagates a flag's value to its aliases by calling Set(String()), so returning the Go default map representation (map[k:v]) would cause Set to fail and wipe the map.