osargs

package
v1.232.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 3 Imported by: 1 module, 0 packages

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

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

func ParseString(args []string, flagName string) string

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

func ParseStringSlice(args []string, flagName string) []string

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

func ParseStringWithShorthand(args []string, flagName, shorthand string) string

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.

Jump to

Keyboard shortcuts

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