Documentation
¶
Index ¶
- func GetAs[T any](fs *FlagSet, name string) (T, error)
- func IsHelpRequested(err error) bool
- func IsVersionRequested(err error) bool
- func RequestHelp(msg string) error
- func RequestVersion(msg string) error
- type BoolValue
- type ErrorHandling
- type Flag
- func (b *Flag[T]) Choices(allowed ...T) *Flag[T]
- func (b *Flag[T]) Deprecated(reason string) *Flag[T]
- func (b *Flag[T]) DisableEnv() *Flag[T]
- func (b *Flag[T]) Env(key string) *Flag[T]
- func (b *Flag[T]) Group(name string) *Flag[T]
- func (b *Flag[T]) Hidden() *Flag[T]
- func (b *Flag[T]) Metavar(s string) *Flag[T]
- func (b *Flag[T]) Required() *Flag[T]
- func (b *Flag[T]) Validator(fn func(T) bool) *Flag[T]
- func (b *Flag[T]) Value() *T
- type FlagItem
- type FlagPrintMode
- type FlagSet
- func (f *FlagSet) Arg(i int) (string, bool)
- func (f *FlagSet) Args() []string
- func (f *FlagSet) Bool(name string, def bool, usage string) *boolFlag
- func (f *FlagSet) BoolP(name, short string, def bool, usage string) *boolFlag
- func (f *FlagSet) BoolSlice(name string, def []bool, usage string) *SliceFlag[[]bool]
- func (f *FlagSet) BoolSliceP(name, short string, def []bool, usage string) *SliceFlag[[]bool]
- func (f *FlagSet) BoolSliceVar(ptr *[]bool, name string, def []bool, usage string) *SliceFlag[[]bool]
- func (f *FlagSet) BoolSliceVarP(ptr *[]bool, name, short string, def []bool, usage string) *SliceFlag[[]bool]
- func (f *FlagSet) BoolVar(ptr *bool, name string, def bool, usage string) *boolFlag
- func (f *FlagSet) BoolVarP(ptr *bool, name, short string, def bool, usage string) *boolFlag
- func (f *FlagSet) Description(s string)
- func (f *FlagSet) DescriptionIndent(indent int)
- func (f *FlagSet) DescriptionMaxLen(line int)
- func (f *FlagSet) DisableHelp()
- func (f *FlagSet) DisableVersion()
- func (f *FlagSet) Duration(name string, def time.Duration, usage string) *Flag[time.Duration]
- func (f *FlagSet) DurationP(name, short string, def time.Duration, usage string) *Flag[time.Duration]
- func (f *FlagSet) DurationSlice(name string, def []time.Duration, usage string) *SliceFlag[[]time.Duration]
- func (f *FlagSet) DurationSliceP(name, short string, def []time.Duration, usage string) *SliceFlag[[]time.Duration]
- func (f *FlagSet) DurationSliceVar(ptr *[]time.Duration, name string, def []time.Duration, usage string) *SliceFlag[[]time.Duration]
- func (f *FlagSet) DurationSliceVarP(ptr *[]time.Duration, name, short string, def []time.Duration, usage string) *SliceFlag[[]time.Duration]
- func (f *FlagSet) DurationVar(ptr *time.Duration, name string, def time.Duration, usage string) *Flag[time.Duration]
- func (f *FlagSet) DurationVarP(ptr *time.Duration, name, short string, def time.Duration, usage string) *Flag[time.Duration]
- func (f *FlagSet) EnvPrefix(prefix string)
- func (f *FlagSet) File(name string, def *os.File, usage string) *Flag[*os.File]
- func (f *FlagSet) FileP(name, short string, def *os.File, usage string) *Flag[*os.File]
- func (f *FlagSet) FileSlice(name string, def []*os.File, usage string) *SliceFlag[[]*os.File]
- func (f *FlagSet) FileSliceP(name, short string, def []*os.File, usage string) *SliceFlag[[]*os.File]
- func (f *FlagSet) FileSliceVar(ptr *[]*os.File, name string, def []*os.File, usage string) *SliceFlag[[]*os.File]
- func (f *FlagSet) FileSliceVarP(ptr *[]*os.File, name, short string, def []*os.File, usage string) *SliceFlag[[]*os.File]
- func (f *FlagSet) FileVar(ptr **os.File, name string, def *os.File, usage string) *Flag[*os.File]
- func (f *FlagSet) FileVarP(ptr **os.File, name, short string, def *os.File, usage string) *Flag[*os.File]
- func (f *FlagSet) Float32(name string, def float32, usage string) *Flag[float32]
- func (f *FlagSet) Float32P(name, short string, def float32, usage string) *Flag[float32]
- func (f *FlagSet) Float32Slice(name string, def []float32, usage string) *SliceFlag[[]float32]
- func (f *FlagSet) Float32SliceP(name, short string, def []float32, usage string) *SliceFlag[[]float32]
- func (f *FlagSet) Float32SliceVar(ptr *[]float32, name string, def []float32, usage string) *SliceFlag[[]float32]
- func (f *FlagSet) Float32SliceVarP(ptr *[]float32, name, short string, def []float32, usage string) *SliceFlag[[]float32]
- func (f *FlagSet) Float32Var(ptr *float32, name string, def float32, usage string) *Flag[float32]
- func (f *FlagSet) Float32VarP(ptr *float32, name, short string, def float32, usage string) *Flag[float32]
- func (f *FlagSet) Float64(name string, def float64, usage string) *Flag[float64]
- func (f *FlagSet) Float64P(name, short string, def float64, usage string) *Flag[float64]
- func (f *FlagSet) Float64Slice(name string, def []float64, usage string) *SliceFlag[[]float64]
- func (f *FlagSet) Float64SliceP(name, short string, def []float64, usage string) *SliceFlag[[]float64]
- func (f *FlagSet) Float64SliceVar(ptr *[]float64, name string, def []float64, usage string) *SliceFlag[[]float64]
- func (f *FlagSet) Float64SliceVarP(ptr *[]float64, name, short string, def []float64, usage string) *SliceFlag[[]float64]
- func (f *FlagSet) Float64Var(ptr *float64, name string, def float64, usage string) *Flag[float64]
- func (f *FlagSet) Float64VarP(ptr *float64, name, short string, def float64, usage string) *Flag[float64]
- func (f *FlagSet) Get(name string) (any, error)
- func (f *FlagSet) Globaldelimiter(s string)
- func (f *FlagSet) Group(name string, flag *baseFlag)
- func (f *FlagSet) HostPort(name, def string, usage string) *Flag[string]
- func (f *FlagSet) HostPortP(name, short, def string, usage string) *Flag[string]
- func (f *FlagSet) HostPortSlice(name string, def []string, usage string) *SliceFlag[[]string]
- func (f *FlagSet) HostPortSliceP(name, short string, def []string, usage string) *SliceFlag[[]string]
- func (f *FlagSet) HostPortSliceVar(ptr *[]string, name string, def []string, usage string) *SliceFlag[[]string]
- func (f *FlagSet) HostPortSliceVarP(ptr *[]string, name, short string, def []string, usage string) *SliceFlag[[]string]
- func (f *FlagSet) HostPortVar(ptr *string, name string, def string, usage string) *Flag[string]
- func (f *FlagSet) HostPortVarP(ptr *string, name, short string, def string, usage string) *Flag[string]
- func (f *FlagSet) IP(name string, def net.IP, usage string) *Flag[net.IP]
- func (f *FlagSet) IPMask(name string, def net.IPMask, usage string) *Flag[net.IPMask]
- func (f *FlagSet) IPMaskP(name, short string, def net.IPMask, usage string) *Flag[net.IPMask]
- func (f *FlagSet) IPMaskSlice(name string, def []net.IPMask, usage string) *SliceFlag[[]net.IPMask]
- func (f *FlagSet) IPMaskSliceP(name, short string, def []net.IPMask, usage string) *SliceFlag[[]net.IPMask]
- func (f *FlagSet) IPMaskSliceVar(ptr *[]net.IPMask, name string, def []net.IPMask, usage string) *SliceFlag[[]net.IPMask]
- func (f *FlagSet) IPMaskSliceVarP(ptr *[]net.IPMask, name, short string, def []net.IPMask, usage string) *SliceFlag[[]net.IPMask]
- func (f *FlagSet) IPMaskVar(ptr *net.IPMask, name string, def net.IPMask, usage string) *Flag[net.IPMask]
- func (f *FlagSet) IPMaskVarP(ptr *net.IPMask, name, short string, def net.IPMask, usage string) *Flag[net.IPMask]
- func (f *FlagSet) IPP(name, short string, def net.IP, usage string) *Flag[net.IP]
- func (f *FlagSet) IPSlice(name string, def []net.IP, usage string) *SliceFlag[[]net.IP]
- func (f *FlagSet) IPSliceP(name, short string, def []net.IP, usage string) *SliceFlag[[]net.IP]
- func (f *FlagSet) IPSliceVar(ptr *[]net.IP, name string, def []net.IP, usage string) *SliceFlag[[]net.IP]
- func (f *FlagSet) IPSliceVarP(ptr *[]net.IP, name, short string, def []net.IP, usage string) *SliceFlag[[]net.IP]
- func (f *FlagSet) IPVar(ptr *net.IP, name string, def net.IP, usage string) *Flag[net.IP]
- func (f *FlagSet) IPVarP(ptr *net.IP, name, short string, def net.IP, usage string) *Flag[net.IP]
- func (f *FlagSet) IgnoreInvalidEnv(enable bool)
- func (f *FlagSet) Int(name string, def int, usage string) *Flag[int]
- func (f *FlagSet) IntP(name, short string, def int, usage string) *Flag[int]
- func (f *FlagSet) IntSlice(name string, def []int, usage string) *SliceFlag[[]int]
- func (f *FlagSet) IntSliceP(name, short string, def []int, usage string) *SliceFlag[[]int]
- func (f *FlagSet) IntSliceVar(ptr *[]int, name string, def []int, usage string) *SliceFlag[[]int]
- func (f *FlagSet) IntSliceVarP(ptr *[]int, name, short string, def []int, usage string) *SliceFlag[[]int]
- func (f *FlagSet) IntVar(ptr *int, name string, def int, usage string) *Flag[int]
- func (f *FlagSet) IntVarP(ptr *int, name, short string, def int, usage string) *Flag[int]
- func (f *FlagSet) ListenAddr(name string, def *net.TCPAddr, usage string) *Flag[*net.TCPAddr]
- func (f *FlagSet) ListenAddrP(name, short string, def *net.TCPAddr, usage string) *Flag[*net.TCPAddr]
- func (f *FlagSet) ListenAddrSlice(name string, def []*net.TCPAddr, usage string) *SliceFlag[[]*net.TCPAddr]
- func (f *FlagSet) ListenAddrSliceP(name, short string, def []*net.TCPAddr, usage string) *SliceFlag[[]*net.TCPAddr]
- func (f *FlagSet) ListenAddrSliceVar(ptr *[]*net.TCPAddr, name string, def []*net.TCPAddr, usage string) *SliceFlag[[]*net.TCPAddr]
- func (f *FlagSet) ListenAddrSliceVarP(ptr *[]*net.TCPAddr, name, short string, def []*net.TCPAddr, usage string) *SliceFlag[[]*net.TCPAddr]
- func (f *FlagSet) ListenAddrVar(ptr **net.TCPAddr, name string, def *net.TCPAddr, usage string) *Flag[*net.TCPAddr]
- func (f *FlagSet) ListenAddrVarP(ptr **net.TCPAddr, name, short string, def *net.TCPAddr, usage string) *Flag[*net.TCPAddr]
- func (f *FlagSet) MustGet(name string) any
- func (f *FlagSet) Name() string
- func (f *FlagSet) Note(s string)
- func (f *FlagSet) Output() io.Writer
- func (f *FlagSet) Parse(args []string) error
- func (f *FlagSet) PrintDefaults()
- func (f *FlagSet) PrintDescription(w io.Writer, width int)
- func (f *FlagSet) PrintNotes(w io.Writer, width int)
- func (f *FlagSet) PrintTitle(w io.Writer)
- func (f *FlagSet) PrintUsage(w io.Writer, mode FlagPrintMode)
- func (f *FlagSet) RequirePositional(n int)
- func (f *FlagSet) SchemaHostPort(name, def string, usage string) *Flag[string]
- func (f *FlagSet) SchemaHostPortP(name, short, def string, usage string) *Flag[string]
- func (f *FlagSet) SchemaHostPortSlice(name string, def []string, usage string) *SliceFlag[[]string]
- func (f *FlagSet) SchemaHostPortSliceP(name, short string, def []string, usage string) *SliceFlag[[]string]
- func (f *FlagSet) SchemaHostPortSliceVar(ptr *[]string, name string, def []string, usage string) *SliceFlag[[]string]
- func (f *FlagSet) SchemaHostPortSliceVarP(ptr *[]string, name, short string, def []string, usage string) *SliceFlag[[]string]
- func (f *FlagSet) SchemaHostPortVar(ptr *string, name string, def string, usage string) *Flag[string]
- func (f *FlagSet) SchemaHostPortVarP(ptr *string, name, short string, def string, usage string) *Flag[string]
- func (f *FlagSet) SetGetEnvFn(fn func(string) string)
- func (f *FlagSet) SetOutput(w io.Writer)
- func (f *FlagSet) Sorted(enable bool)
- func (f *FlagSet) String(name string, def string, usage string) *Flag[string]
- func (f *FlagSet) StringP(name, short string, def string, usage string) *Flag[string]
- func (f *FlagSet) StringSlice(name string, def []string, usage string) *SliceFlag[[]string]
- func (f *FlagSet) StringSliceP(name, short string, def []string, usage string) *SliceFlag[[]string]
- func (f *FlagSet) StringSliceVar(ptr *[]string, name string, def []string, usage string) *SliceFlag[[]string]
- func (f *FlagSet) StringSliceVarP(ptr *[]string, name, short string, def []string, usage string) *SliceFlag[[]string]
- func (f *FlagSet) StringVar(ptr *string, name string, def string, usage string) *Flag[string]
- func (f *FlagSet) StringVarP(ptr *string, name, short string, def string, usage string) *Flag[string]
- func (f *FlagSet) Title(s string)
- func (f *FlagSet) URL(name string, def *url.URL, usage string) *Flag[*url.URL]
- func (f *FlagSet) URLP(name, short string, def *url.URL, usage string) *Flag[*url.URL]
- func (f *FlagSet) URLSlice(name string, def []*url.URL, usage string) *SliceFlag[[]*url.URL]
- func (f *FlagSet) URLSliceP(name, short string, def []*url.URL, usage string) *SliceFlag[[]*url.URL]
- func (f *FlagSet) URLSliceVar(ptr *[]*url.URL, name string, def []*url.URL, usage string) *SliceFlag[[]*url.URL]
- func (f *FlagSet) URLSliceVarP(ptr *[]*url.URL, name, short string, def []*url.URL, usage string) *SliceFlag[[]*url.URL]
- func (f *FlagSet) URLVar(ptr **url.URL, name string, def *url.URL, usage string) *Flag[*url.URL]
- func (f *FlagSet) URLVarP(ptr **url.URL, name, short string, def *url.URL, usage string) *Flag[*url.URL]
- func (f *FlagSet) UsagePrintMode(mode FlagPrintMode)
- func (f *FlagSet) Version(s string)
- type HasDelimiter
- type HelpRequested
- type SliceFlag
- type SliceFlagItem
- type SliceMarker
- type StrictBool
- type Value
- type VersionRequested
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsHelpRequested ¶
IsHelpRequested checks if the error is a HelpRequested sentinel.
func IsVersionRequested ¶
IsVersionRequested checks if the error is a VersionRequested sentinel
func RequestHelp ¶
RequestHelp returns an error with type HelpRequested and the given message.
func RequestVersion ¶
RequestVersion returns an error with type VersionRequested and the given message.
Types ¶
type BoolValue ¶
BoolValue wraps BaseValue[bool] and implements StrictBool.
func (*BoolValue) IsStrictBool ¶
IsStrictBool reports true if the flag must be passed explicitly as true/false.
type ErrorHandling ¶
type ErrorHandling int
const ( // ContinueOnError will return an err from Parse() if an error is found ContinueOnError ErrorHandling = iota // ExitOnError will call os.Exit(2) if an error is found when parsing ExitOnError // PanicOnError will panic() if an error is found when parsing flags PanicOnError )
type Flag ¶
type Flag[T any] struct { // contains filtered or unexported fields }
Flag is a generic type for defining scalar.
func (*Flag[T]) Deprecated ¶
Deprecated marks the flag as deprecated, and the provided reason is shown in help output.
func (*Flag[T]) DisableEnv ¶
DisableEnv disables reading from environment variables for this flag, even if a global prefix is configured via the FlagSet.
func (*Flag[T]) Env ¶
Env sets the environment variable name that can override this flag. If not set explicitly, a default name is generated based on the flag name.
func (*Flag[T]) Group ¶
Group assigns this flag to a mutual exclusion group. Flags in the same group are mutually exclusive and cannot be used together.
func (*Flag[T]) Metavar ¶
Metavar sets the placeholder name shown in help output for the flag value. If not set, it defaults to the uppercase flag name.
func (*Flag[T]) Required ¶
Required marks this flag as required. Parsing will fail if it is not provided.
type FlagItem ¶
type FlagItem[T any] struct { // contains filtered or unexported fields }
FlagItem is a generic flag value holder for scalar types. It implements the Value interface and tracks the parsed value, default value, and whether the value has been changed.
func NewFlagItem ¶
func NewFlagItem[T any](ptr *T, def T, parse func(string) (T, error), format func(T) string) *FlagItem[T]
NewFlagItem constructs a new BaseValue for scalar flags. The parse and format functions must be provided to convert values to/from strings.
func (*FlagItem[T]) SetValidator ¶
SetValidator sets a validation callback for this flag.
type FlagPrintMode ¶
type FlagPrintMode int
FlagPrintMode defines how flags are displayed in usage.
const ( PrintShort FlagPrintMode = iota // Show only short flags: -x PrintLong // Show only long flags: --xyz PrintBoth // Show both: -x|--xyz PrintFlags // Prints "Flags" PrintNone // Hide all flags )
type FlagSet ¶
type FlagSet struct {
Usage func() // custom usage printer
// contains filtered or unexported fields
}
FlagSet stores configuration and registered flags for parsing.
func NewFlagSet ¶
func NewFlagSet(name string, errorHandling ErrorHandling) *FlagSet
NewFlagSet creates a new FlagSet with a name and error behavior.
func (*FlagSet) Bool ¶
Bool defines a bool flag with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) BoolP ¶
BoolP defines a bool flag with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) BoolSlice ¶
BoolSlice defines a bool slice flag with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) BoolSliceP ¶
func (*FlagSet) BoolSliceVar ¶
func (f *FlagSet) BoolSliceVar(ptr *[]bool, name string, def []bool, usage string) *SliceFlag[[]bool]
BoolSlice defines a bool slice flag with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) BoolSliceVarP ¶
func (f *FlagSet) BoolSliceVarP(ptr *[]bool, name, short string, def []bool, usage string) *SliceFlag[[]bool]
BoolSliceP defines a bool flag with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) BoolVar ¶
BoolVar defines a bool flag with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) BoolVarP ¶
BoolVarP defines a bool flag with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Description ¶
Description sets optional text before usage help.
func (*FlagSet) DescriptionIndent ¶
DescriptionIndent sets the indentation for descriptions.
func (*FlagSet) DescriptionMaxLen ¶
DescriptionMaxLen sets the max line length for descriptions.
func (*FlagSet) DisableHelp ¶
func (f *FlagSet) DisableHelp()
DisableHelp disables automatic help flag registration.
func (*FlagSet) DisableVersion ¶
func (f *FlagSet) DisableVersion()
DisableVersion disables automatic version flag registration.
func (*FlagSet) Duration ¶
Duration defines a duration flag with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) DurationP ¶
func (f *FlagSet) DurationP(name, short string, def time.Duration, usage string) *Flag[time.Duration]
DurationP defines a duration flag with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) DurationSlice ¶
func (f *FlagSet) DurationSlice(name string, def []time.Duration, usage string) *SliceFlag[[]time.Duration]
DurationSlice defines a duration slice flag with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) DurationSliceP ¶
func (f *FlagSet) DurationSliceP(name, short string, def []time.Duration, usage string) *SliceFlag[[]time.Duration]
DurationSliceP defines a duration flag with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) DurationSliceVar ¶
func (f *FlagSet) DurationSliceVar(ptr *[]time.Duration, name string, def []time.Duration, usage string) *SliceFlag[[]time.Duration]
DurationSliceVar defines a duration slice flag with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().// The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) DurationSliceVarP ¶
func (f *FlagSet) DurationSliceVarP(ptr *[]time.Duration, name, short string, def []time.Duration, usage string) *SliceFlag[[]time.Duration]
DurationSliceVarP defines a duration slice flag with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) DurationVar ¶
func (f *FlagSet) DurationVar(ptr *time.Duration, name string, def time.Duration, usage string) *Flag[time.Duration]
DurationVar defines a duration flag with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) DurationVarP ¶
func (f *FlagSet) DurationVarP(ptr *time.Duration, name, short string, def time.Duration, usage string) *Flag[time.Duration]
DurationVarP defines a duration flag with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) File ¶
File defines a file flag with the specified name, default value, and usage string. Each input string is interpreted as a file path and opened using os.Open. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) FileP ¶
FileP defines a file flag with the specified name, shorthand, default value, and usage string. Each input string is interpreted as a file path and opened using os.Open. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) FileSlice ¶
FileSlice defines a file slice flag with the specified name, default value, and usage string. Each input string is interpreted as a file path and opened using os.Open. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) FileSliceP ¶
func (f *FlagSet) FileSliceP(name, short string, def []*os.File, usage string) *SliceFlag[[]*os.File]
FileSliceP defines a file slice flag with the specified name, shorthand, default value, and usage string. Each input string is interpreted as a file path and opened using os.Open. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) FileSliceVar ¶
func (f *FlagSet) FileSliceVar(ptr *[]*os.File, name string, def []*os.File, usage string) *SliceFlag[[]*os.File]
FileSliceVar defines a file slice flag with the specified name, default value, and usage string. Each input string is interpreted as a file path and opened using os.Open. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) FileSliceVarP ¶
func (f *FlagSet) FileSliceVarP(ptr *[]*os.File, name, short string, def []*os.File, usage string) *SliceFlag[[]*os.File]
FileSliceVarP defines a file slice flag with the specified name, shorthand, default value, and usage string. Each input string is interpreted as a file path and opened using os.Open. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) FileVar ¶
FileVar defines a file flag with the specified name, default value, and usage string. Each input string is interpreted as a file path and opened using os.Open. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) FileVarP ¶
func (f *FlagSet) FileVarP(ptr **os.File, name, short string, def *os.File, usage string) *Flag[*os.File]
FileVarP defines a file flag with the specified name, shorthand, default value, and usage string. Each input string is interpreted as a file path and opened using os.Open. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float32 ¶
Float32 defines a float32 flag with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float32P ¶
Float32P defines a float32 flag with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float32Slice ¶
Float32Slice defines a float32 slice flag with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float32SliceP ¶
func (f *FlagSet) Float32SliceP(name, short string, def []float32, usage string) *SliceFlag[[]float32]
Float32SliceP defines a float32 slice flag with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float32SliceVar ¶
func (f *FlagSet) Float32SliceVar(ptr *[]float32, name string, def []float32, usage string) *SliceFlag[[]float32]
Float32SliceVar defines a float32 slice flag with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float32SliceVarP ¶
func (f *FlagSet) Float32SliceVarP(ptr *[]float32, name, short string, def []float32, usage string) *SliceFlag[[]float32]
Float32SliceVarP defines a float32 slice flag with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float32Var ¶
Float32Var defines a float32 flag with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float32VarP ¶
func (f *FlagSet) Float32VarP(ptr *float32, name, short string, def float32, usage string) *Flag[float32]
Float32VarP defines a float32 flag with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float64 ¶
Float64 defines a float64 flag with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float64P ¶
Float64P defines a float64 flag with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float64Slice ¶
Float64Slice defines a float64 slice flag with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float64SliceP ¶
func (f *FlagSet) Float64SliceP(name, short string, def []float64, usage string) *SliceFlag[[]float64]
Float64SliceP defines a float64 slice flag with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float64SliceVar ¶
func (f *FlagSet) Float64SliceVar(ptr *[]float64, name string, def []float64, usage string) *SliceFlag[[]float64]
Float64SliceVar defines a float64 slice flag with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float64SliceVarP ¶
func (f *FlagSet) Float64SliceVarP(ptr *[]float64, name, short string, def []float64, usage string) *SliceFlag[[]float64]
Float64SliceVarP defines a float64 slice flag with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float64Var ¶
Float64Var defines a float64 flag with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Float64VarP ¶
func (f *FlagSet) Float64VarP(ptr *float64, name, short string, def float64, usage string) *Flag[float64]
Float64VarP defines a float64 flag with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) Globaldelimiter ¶
Globaldelimiter sets the default delimiter for slice flags.
func (*FlagSet) HostPort ¶
HostPort defines a string flag that must represent a valid host:port pair, with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) HostPortP ¶
HostPortP defines a string flag that must represent a valid host:port pair, with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) HostPortSlice ¶
HostPortSlice defines a string slice flag where each element must be a valid host:port pair, with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) HostPortSliceP ¶
func (f *FlagSet) HostPortSliceP(name, short string, def []string, usage string) *SliceFlag[[]string]
HostPortSliceP defines a string slice flag where each element must be a valid host:port pair, with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) HostPortSliceVar ¶
func (f *FlagSet) HostPortSliceVar(ptr *[]string, name string, def []string, usage string) *SliceFlag[[]string]
HostPortSliceVar defines a string slice flag where each element must be a valid host:port pair, with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) HostPortSliceVarP ¶
func (f *FlagSet) HostPortSliceVarP(ptr *[]string, name, short string, def []string, usage string) *SliceFlag[[]string]
HostPortSliceVarP defines a string slice flag where each element must be a valid host:port pair, with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) HostPortVar ¶
HostPortVar defines a string flag that must represent a valid host:port pair, with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) HostPortVarP ¶
func (f *FlagSet) HostPortVarP(ptr *string, name, short string, def string, usage string) *Flag[string]
HostPortVarP defines a string flag that must represent a valid host:port pair, with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IP ¶
IP defines a net.IP flag with the specified name, default value, and usage. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IPMask ¶
IPMask defines a net.IPMask flag with name, default value, and usage string. The input must be in dotted decimal format (e.g., "255.255.255.0"). Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IPMaskP ¶
IPMaskP defines a net.IPMask flag with name, shorthand, default value, and usage string. The input must be in dotted decimal format (e.g., "255.255.255.0"). Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IPMaskSlice ¶
IPMaskSlice defines a []net.IPMask slice flag with name, default value, and usage string. Each element must be in dotted decimal format (e.g., "255.255.255.0"). Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IPMaskSliceP ¶
func (f *FlagSet) IPMaskSliceP(name, short string, def []net.IPMask, usage string) *SliceFlag[[]net.IPMask]
IPMaskSliceP defines a []net.IPMask slice flag with name, shorthand, default value, and usage string. Each element must be in dotted decimal format (e.g., "255.255.255.0"). Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IPMaskSliceVar ¶
func (f *FlagSet) IPMaskSliceVar(ptr *[]net.IPMask, name string, def []net.IPMask, usage string) *SliceFlag[[]net.IPMask]
IPMaskSliceVar defines a []net.IPMask slice flag with name, default value, and usage string. Each element must be in dotted decimal format (e.g., "255.255.255.0"). The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IPMaskSliceVarP ¶
func (f *FlagSet) IPMaskSliceVarP(ptr *[]net.IPMask, name, short string, def []net.IPMask, usage string) *SliceFlag[[]net.IPMask]
IPMaskSliceVarP defines a []net.IPMask slice flag with name, shorthand, default value, and usage string. Each element must be in dotted decimal format (e.g., "255.255.255.0"). The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IPMaskVar ¶
func (f *FlagSet) IPMaskVar(ptr *net.IPMask, name string, def net.IPMask, usage string) *Flag[net.IPMask]
IPMaskVar defines a net.IPMask flag with name, default value, and usage string. The input must be in dotted decimal format (e.g., "255.255.255.0"). The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IPMaskVarP ¶
func (f *FlagSet) IPMaskVarP(ptr *net.IPMask, name, short string, def net.IPMask, usage string) *Flag[net.IPMask]
IPMaskVarP defines a net.IPMask flag with name, shorthand, default value, and usage string. The input must be in dotted decimal format (e.g., "255.255.255.0"). The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IPP ¶
IPP defines a net.IP flag with the specified name, shorthand, default value, and usage. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IPSlice ¶
IPSlice defines a []net.IP slice flag with name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IPSliceP ¶
IPSliceP defines a []net.IP slice flag with name, shorthand, default value, and usage string. It returns the slice flag for chaining.
func (*FlagSet) IPSliceVar ¶
func (f *FlagSet) IPSliceVar(ptr *[]net.IP, name string, def []net.IP, usage string) *SliceFlag[[]net.IP]
IPSliceVar defines a []net.IP slice flag with name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IPSliceVarP ¶
func (f *FlagSet) IPSliceVarP(ptr *[]net.IP, name, short string, def []net.IP, usage string) *SliceFlag[[]net.IP]
IPSliceVarP defines a []net.IP slice flag with name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IPVar ¶
IPVar defines a net.IP flag with the specified name, default value, and usage. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IPVarP ¶
IPVarP defines a net.IP flag with the specified name, shorthand, default value, and usage. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IgnoreInvalidEnv ¶
IgnoreInvalidEnv skips env vars that cannot be parsed.
func (*FlagSet) Int ¶
Int defines an int flag with specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IntP ¶
IntP defines an int flag with specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IntSlice ¶
IntSlice defines a []int slice flag with the specified name, default value, and usage. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IntSliceP ¶
IntSliceP defines a []int slice flag with the specified name, shorthand, default value, and usage. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IntSliceVar ¶
IntSliceVar defines a []int slice flag with the specified name, default value, and usage. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IntSliceVarP ¶
func (f *FlagSet) IntSliceVarP(ptr *[]int, name, short string, def []int, usage string) *SliceFlag[[]int]
IntSliceVarP defines a []int slice flag with the specified name, shorthand, default value, and usage. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IntVar ¶
IntVar defines an int flag with specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) IntVarP ¶
IntVarP defines an int flag with specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) ListenAddr ¶
ListenAddr defines a *net.TCPAddr flag with the specified name, default value, and usage string. The value is parsed using net.ResolveTCPAddr with "tcp" as the network. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) ListenAddrP ¶
func (f *FlagSet) ListenAddrP(name, short string, def *net.TCPAddr, usage string) *Flag[*net.TCPAddr]
ListenAddrP defines a *net.TCPAddr flag with the specified name, shorthand, default value, and usage string. The value is parsed using net.ResolveTCPAddr with "tcp" as the network. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) ListenAddrSlice ¶
func (f *FlagSet) ListenAddrSlice(name string, def []*net.TCPAddr, usage string) *SliceFlag[[]*net.TCPAddr]
ListenAddrSlice defines a []*net.TCPAddr slice flag without a shorthand. Each element is parsed using net.ResolveTCPAddr with "tcp" as the network. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) ListenAddrSliceP ¶
func (f *FlagSet) ListenAddrSliceP(name, short string, def []*net.TCPAddr, usage string) *SliceFlag[[]*net.TCPAddr]
ListenAddrSliceP defines a []*net.TCPAddr slice flag with a name, shorthand, default value, and usage string. Each element is parsed using net.ResolveTCPAddr with "tcp" as the network. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) ListenAddrSliceVar ¶
func (f *FlagSet) ListenAddrSliceVar(ptr *[]*net.TCPAddr, name string, def []*net.TCPAddr, usage string) *SliceFlag[[]*net.TCPAddr]
ListenAddrSliceVar defines a []*net.TCPAddr slice flag without a shorthand. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) ListenAddrSliceVarP ¶
func (f *FlagSet) ListenAddrSliceVarP(ptr *[]*net.TCPAddr, name, short string, def []*net.TCPAddr, usage string) *SliceFlag[[]*net.TCPAddr]
ListenAddrSliceVarP defines a []*net.TCPAddr slice flag with a name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) ListenAddrVar ¶
func (f *FlagSet) ListenAddrVar(ptr **net.TCPAddr, name string, def *net.TCPAddr, usage string) *Flag[*net.TCPAddr]
ListenAddrVar defines a *net.TCPAddr flag with the specified name, default value, and usage string. The value is parsed using net.ResolveTCPAddr with "tcp" as the network. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value
func (*FlagSet) ListenAddrVarP ¶
func (f *FlagSet) ListenAddrVarP(ptr **net.TCPAddr, name, short string, def *net.TCPAddr, usage string) *Flag[*net.TCPAddr]
ListenAddrVarP defines a *net.TCPAddr flag with the specified name, shorthand, default value, and usage string. The value is parsed using net.ResolveTCPAddr with "tcp" as the network. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value
func (*FlagSet) Parse ¶
Parse parses CLI arguments, env vars, built-in help/version, and validations.
func (*FlagSet) PrintDefaults ¶
func (f *FlagSet) PrintDefaults()
PrintDefaults prints the detailed help for all flags.
func (*FlagSet) PrintDescription ¶
PrintDescription prints prolog text above the flags.
func (*FlagSet) PrintNotes ¶
PrintNotes prints epilog text below the usage block.
func (*FlagSet) PrintTitle ¶
PrintTitle prints the configured title above the usage.
func (*FlagSet) PrintUsage ¶
func (f *FlagSet) PrintUsage(w io.Writer, mode FlagPrintMode)
PrintUsage prints the one-line usage header based on mode.
func (*FlagSet) RequirePositional ¶
RequirePositional sets the number of required positional args.
func (*FlagSet) SchemaHostPort ¶
SchemaHostPort defines a string flag that must match scheme://host:port format, with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) SchemaHostPortP ¶
SchemaHostPortP defines a string flag that must match scheme://host:port format, with a shorthand, default value, and usage string. The value is parsed with url.Parse and must include a scheme and host. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) SchemaHostPortSlice ¶
SchemaHostPortSlice defines a string slice flag that must represent a valid schema://host:port pair, with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) SchemaHostPortSliceP ¶
func (f *FlagSet) SchemaHostPortSliceP(name, short string, def []string, usage string) *SliceFlag[[]string]
SchemaHostPortSliceP defines a string flag that must represent a valid schema://host:port pair, with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) SchemaHostPortSliceVar ¶
func (f *FlagSet) SchemaHostPortSliceVar(ptr *[]string, name string, def []string, usage string) *SliceFlag[[]string]
SchemaHostPortSliceVar defines a string flag that must represent a valid schema://host:port pair, with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value
func (*FlagSet) SchemaHostPortSliceVarP ¶
func (f *FlagSet) SchemaHostPortSliceVarP(ptr *[]string, name, short string, def []string, usage string) *SliceFlag[[]string]
SchemaHostPortSliceVarP defines a string flag that must represent a valid schema://host:port pair, with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value
func (*FlagSet) SchemaHostPortVar ¶
func (f *FlagSet) SchemaHostPortVar(ptr *string, name string, def string, usage string) *Flag[string]
SchemaHostPortVar defines a string flag that must match scheme://host:port format, with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) SchemaHostPortVarP ¶
func (f *FlagSet) SchemaHostPortVarP(ptr *string, name, short string, def string, usage string) *Flag[string]
SchemaHostPortVarP defines a string flag that must match scheme://host:port format, with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) SetGetEnvFn ¶
SetGetEnvFn overrides the env lookup function.
func (*FlagSet) String ¶
String defines a string flag with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) StringP ¶
StringP defines a string flag with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) StringSlice ¶
StringSlice defines a string slice flag with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) StringSliceP ¶
StringSliceP defines a string slice flag with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) StringSliceVar ¶
func (f *FlagSet) StringSliceVar(ptr *[]string, name string, def []string, usage string) *SliceFlag[[]string]
StringSlice defines a string slice flag with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) StringSliceVarP ¶
func (f *FlagSet) StringSliceVarP(ptr *[]string, name, short string, def []string, usage string) *SliceFlag[[]string]
StringSliceP defines a string flag with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) StringVar ¶
StringVar defines a string flag with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) StringVarP ¶
func (f *FlagSet) StringVarP(ptr *string, name, short string, def string, usage string) *Flag[string]
StringVarP defines a string flag with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) URL ¶
URL defines a *url.URL flag with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) URLP ¶
URLP defines a *url.URL flag with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) URLSlice ¶
URLSlice defines a *url.URL slice flag with the specified name, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) URLSliceP ¶
func (f *FlagSet) URLSliceP(name, short string, def []*url.URL, usage string) *SliceFlag[[]*url.URL]
URLSliceP defines a *url.URL slice flag with the specified name, shorthand, default value, and usage string. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) URLSliceVar ¶
func (f *FlagSet) URLSliceVar(ptr *[]*url.URL, name string, def []*url.URL, usage string) *SliceFlag[[]*url.URL]
URLSlice defines a *url.URL slice flag with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) URLSliceVarP ¶
func (f *FlagSet) URLSliceVarP(ptr *[]*url.URL, name, short string, def []*url.URL, usage string) *SliceFlag[[]*url.URL]
URLSliceP defines a *url.URL flag with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) URLVar ¶
URLVar defines a *url.URL flag with the specified name, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) URLVarP ¶
func (f *FlagSet) URLVarP(ptr **url.URL, name, short string, def *url.URL, usage string) *Flag[*url.URL]
URLVarP defines a *url.URL flag with the specified name, shorthand, default value, and usage string. The parsed value is stored in the provided pointer. Returns the flag for chaining. Retrieve the parsed value with .Value().
func (*FlagSet) UsagePrintMode ¶
func (f *FlagSet) UsagePrintMode(mode FlagPrintMode)
UsagePrintMode sets the mode for printing usage.
type HasDelimiter ¶
type HasDelimiter interface {
SetDelimiter(string) // Updates the delimiter used during Set()
}
HasDelimiter is implemented by slice flag types that allow custom delimiters for splitting input strings into elements.
type HelpRequested ¶
type HelpRequested struct {
Message string // The full help message to show the user
}
HelpRequested is returned when the built-in help flag (-h or --help) is triggered.
func (*HelpRequested) Error ¶
func (e *HelpRequested) Error() string
Error returns the help message, satisfying the error interface.
type SliceFlag ¶
SliceFlag is a specialized builder for slice-type flags. It embeds FlagBuilder and provides an additional Delimiter method to control how multiple values are split from a single argument.
type SliceFlagItem ¶
type SliceFlagItem[T any] struct { // contains filtered or unexported fields }
SliceFlagItem is a generic flag value holder for slice types. It implements the Value interface for flags that accept multiple values, optionally split by a custom delimiter.
func NewSliceItem ¶
func NewSliceItem[T any]( ptr *[]T, def []T, parse func(string) (T, error), format func(T) string, delimiter string, ) *SliceFlagItem[T]
NewSliceItem constructs a new BaseSliceValue. The default value is defensively copied into the target pointer.
func (*SliceFlagItem[T]) Default ¶
func (v *SliceFlagItem[T]) Default() string
Default returns the default slice as a single string, joined by the delimiter.
func (*SliceFlagItem[T]) Get ¶
func (v *SliceFlagItem[T]) Get() any
Get returns the current slice value.
func (*SliceFlagItem[T]) IsChanged ¶
func (v *SliceFlagItem[T]) IsChanged() bool
IsChanged reports whether the slice value was explicitly set.
func (*SliceFlagItem[T]) Set ¶
func (v *SliceFlagItem[T]) Set(s string) error
Set splits the input string by the delimiter and parses each item.
func (*SliceFlagItem[T]) SetDelimiter ¶
func (v *SliceFlagItem[T]) SetDelimiter(d string)
SetDelimiter sets the delimiter used for splitting input strings into slice elements.
func (*SliceFlagItem[T]) SetValidator ¶
func (v *SliceFlagItem[T]) SetValidator(fn func(T) bool, allowed []T)
SetValidator sets a validation callback for this flag.
type SliceMarker ¶
type SliceMarker interface {
// contains filtered or unexported methods
}
SliceMarker is a marker interface for slice-type flags. It is used internally to distinguish scalar vs. slice values.
type StrictBool ¶
type StrictBool interface {
IsStrictBool() bool
}
StrictBool is an optional interface implemented by flags that can be used without an explicit value (e.g. --verbose sets to true).
type Value ¶
type Value interface {
Set(string) error // Parses and sets the value from a string input
Get() any // Returns the current value as interface{}
Default() string // Returns the default value as a string
IsChanged() bool // Reports whether the flag value was explicitly set
}
Value is the interface implemented by all flag value types. It provides a way to parse and retrieve values from strings.
type VersionRequested ¶
type VersionRequested struct {
Version string // The version string to show the user
}
VersionRequested is returned when the built-in version flag (--version) is triggered.
func (*VersionRequested) Error ¶
func (e *VersionRequested) Error() string
Error returns the version string, satisfying the error interface.
Source Files
¶
- errors.go
- flag.go
- flagset.go
- parser.go
- parser_fsm.go
- types.go
- usage.go
- utils.go
- value_base.go
- value_base_slice.go
- value_bool.go
- value_bool_slice.go
- value_duration.go
- value_duration_slice.go
- value_file.go
- value_file_slices.go
- value_float32.go
- value_float32_slice.go
- value_float64.go
- value_float64_slice.go
- value_host_port.go
- value_host_port_slice.go
- value_int.go
- value_int_slice.go
- value_ip.go
- value_ip_slice.go
- value_ipmask.go
- value_ipmask_slices.go
- value_listen_addr.go
- value_listen_addr_slice.go
- value_schema_host_port.go
- value_schema_host_port_slice.go
- value_string.go
- value_string_slice.go
- value_url.go
- value_url_slice.go
- wrap.go