flag

package
v1.4.3-prerelease09 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 5 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RepeatedStringMap

type RepeatedStringMap map[string]string

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

type StringMap map[string]string

func (*StringMap) Set

func (m *StringMap) Set(value string) error

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

func (m *StringMap) String() 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.

func (*StringMap) Value

func (m *StringMap) Value() map[string]string

Jump to

Keyboard shortcuts

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