Documentation ¶
Index ¶
- func EnumParser[T fmt.Stringer](all ...T) func(val string) (T, error)
- func StringerParser[T ints](index []uint8, name string) func(val string) (T, error)
- type SliceValue
- func (s *SliceValue[T]) Append(val string) error
- func (s *SliceValue[T]) GetSlice() []string
- func (s *SliceValue[T]) Replace(val []string) error
- func (s *SliceValue[T]) Set(val string) error
- func (s *SliceValue[T]) String() string
- func (s *SliceValue[T]) Type() string
- func (s *SliceValue[T]) Unredacted() pflag.Value
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnumParser ¶
EnumParser returns parse function for string based enums.
Types ¶
type SliceValue ¶
type SliceValue[T any] struct { // contains filtered or unexported fields }
SliceValue is a generic pflag.SliceValue for a slice of T.
func NewSliceValue ¶
func NewSliceValue[T any](val []T, p *[]T, parse func(val string) (T, error)) *SliceValue[T]
NewSliceValue returns a new SliceValue[T] with the given value, pointer to a slice of T, and a parse function.
func NewSliceValueWithRedact ¶
func NewSliceValueWithRedact[T any](val []T, p *[]T, parse func(val string) (T, error), redact func(T) string) *SliceValue[T]
NewSliceValueWithRedact returns a new SliceValue[T] and additionally sets custom String() function for T. Redact primary purpose is to redact passwords to prevent them from leaking in logs.
func (*SliceValue[T]) Append ¶
func (s *SliceValue[T]) Append(val string) error
func (*SliceValue[T]) GetSlice ¶
func (s *SliceValue[T]) GetSlice() []string
func (*SliceValue[T]) Replace ¶
func (s *SliceValue[T]) Replace(val []string) error
func (*SliceValue[T]) Set ¶
func (s *SliceValue[T]) Set(val string) error
func (*SliceValue[T]) String ¶
func (s *SliceValue[T]) String() string
func (*SliceValue[T]) Type ¶
func (s *SliceValue[T]) Type() string
func (*SliceValue[T]) Unredacted ¶
func (s *SliceValue[T]) Unredacted() pflag.Value
Unredacted returns a copy of SliceValue[T] without redact function.
type Value ¶
type Value[T any] struct { // contains filtered or unexported fields }
Value is a generic pflag.Value for a T.
func NewValue ¶
NewValue returns a new Value[T] with the given value, pointer to a T, and a parse function.
func NewValueWithRedact ¶
func NewValueWithRedact[T any](val T, p *T, parse func(val string) (T, error), redact func(T) string) *Value[T]
NewValueWithRedact returns a new Value[T] and additionally sets custom String() function. Redact primary purpose is to redact passwords to prevent them from leaking in logs.
func (*Value[T]) Unredacted ¶
Unredacted returns a copy of Value[T] without redact function.