Documentation
¶
Overview ¶
Package osargs parses individual flag values directly from raw os.Args, before Cobra or Viper have processed them. It exists for the small set of callers that need a flag value before normal config loading (e.g. profile or edition pins consulted while building the Viper instance) or as a fallback for commands that run with Cobra's DisableFlagParsing=true (terraform, helmfile, packer, auth exec), where Cobra never populates a flag binding at all.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseString ¶
ParseString extracts a single string flag's value from raw args, or "" if the flag isn't present. Whitespace is trimmed by the caller if needed — this returns the raw pflag-parsed value.
func ParseStringSlice ¶
ParseStringSlice extracts a comma-separated string-slice flag's value from raw args, or nil if the flag isn't present. Handles both `--flag=a,b` and `--flag a,b` syntax via pflag's own StringSlice parser.
func ParseStringWithShorthand ¶
ParseStringWithShorthand extracts a single string flag's value from raw args, matching either its long form (--flagName) or single-character shorthand (-X), or "" if neither is present. Uses pflag's own shorthand support, so it recognizes every syntax pflag does: --flag=value, --flag value, -X=value, -Xvalue (concatenated), and -X value.
Types ¶
This section is empty.