Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoolFlag ¶
type BoolFlag struct { *ScalarFlag[bool] // embeds core builder methods like Env(), Required(), etc. // contains filtered or unexported fields }
BoolFlag provides fluent builder methods for boolean flags, including support for .Strict() to require explicit values.
type BoolValue ¶
type BoolValue struct { *ScalarValue[bool] // contains filtered or unexported fields }
BoolValue holds the internal state of a boolean flag and whether it is strict.
func NewBoolValue ¶
NewBoolValue returns a BoolValue with parse/format logic and default value.
func (*BoolValue) IsStrictBool ¶
IsStrictBool reports whether the flag requires an explicit value (--flag=true/false).
type CounterFlag ¶
type CounterFlag struct { *ScalarFlag[int] // contains filtered or unexported fields }
CounterFlag provides fluent builder methods for counter flags.
func NewCounter ¶
NewCounter creates a new counter flag.
func (*CounterFlag) Max ¶
func (c *CounterFlag) Max(n int) *CounterFlag
Max sets a maximum allowed value for the counter.
type CounterValue ¶
type CounterValue struct { *ScalarValue[int] }
CounterValue is a scalar int that increments on each occurrence.
func NewCounterValue ¶
func NewCounterValue(ptr *int, def int) *CounterValue
NewCounterValue returns a new counter that increments on each Set().
func (*CounterValue) Increment ¶
func (c *CounterValue) Increment() error
Increment increments the counter value.
func (*CounterValue) Set ¶
func (c *CounterValue) Set(s string) error
Set overrides the default Set to increment on empty string.
type ScalarFlag ¶
type ScalarFlag[T any] struct { builder.StaticFlag[T] // contains filtered or unexported fields }
ScalarFlag is the user-facing scalar flag builder.
func RegisterScalar ¶
func RegisterScalar[T any]( reg core.Registry, name, usage string, val scalarValueProvider[T], ptr *T, ) *ScalarFlag[T]
RegisterScalar registers a scalar flag.
func (*ScalarFlag[T]) Changed ¶ added in v0.0.42
func (f *ScalarFlag[T]) Changed() bool
Changed returns true if the value was changed.
func (*ScalarFlag[T]) Choices ¶
func (f *ScalarFlag[T]) Choices(allowed ...T) *ScalarFlag[T]
Choices restricts allowed scalar values.
func (*ScalarFlag[T]) Default ¶ added in v0.0.42
func (f *ScalarFlag[T]) Default() T
Default returns the default value.
func (*ScalarFlag[T]) Finalize ¶ added in v0.0.32
func (f *ScalarFlag[T]) Finalize(fn func(T) T) *ScalarFlag[T]
Finalize sets a custom finalizer function for each
func (*ScalarFlag[T]) Validate ¶
func (f *ScalarFlag[T]) Validate(fn func(T) error) *ScalarFlag[T]
Validate lets you plug in arbitrary per‐element checks.
type ScalarValue ¶
type ScalarValue[T any] struct { // contains filtered or unexported fields }
ScalarValue implements scalar flag parsing, formatting, and validation.
func NewScalarValue ¶
func NewScalarValue[T any](ptr *T, def T, parse func(string) (T, error), format func(T) string) *ScalarValue[T]
NewScalarValue creates a new scalar value.
func (*ScalarValue[T]) Base ¶
func (f *ScalarValue[T]) Base() *ScalarValue[T]
Base returns the underlying value.
func (*ScalarValue[T]) Changed ¶
func (f *ScalarValue[T]) Changed() bool
Changed returns true if the value was changed.
func (*ScalarValue[T]) Default ¶
func (f *ScalarValue[T]) Default() string
Default returns the default value as string.
func (*ScalarValue[T]) Set ¶
func (f *ScalarValue[T]) Set(s string) error
Set parses and stores one entry.