Documentation
¶
Index ¶
- Variables
- type BuiltinBool
- type BuiltinComplex128
- type BuiltinComplex64
- type BuiltinFloat32
- type BuiltinFloat64
- type BuiltinInt
- type BuiltinInt16
- type BuiltinInt32
- type BuiltinInt64
- type BuiltinInt8
- type BuiltinString
- type BuiltinUint
- type BuiltinUint16
- type BuiltinUint32
- type BuiltinUint64
- type BuiltinUint8
- type Dir
- type Enum
- type File
- type Flag
- type FlagCntr
- type ListValues
- type Mkdir
- type Noop
- type OpenFile
- type Range
- type Selector
- type Stopper
- type Translater
Constants ¶
This section is empty.
Variables ¶
var (
ValNotInAllowedListErr = errors.New("Value was not found in the allowed list")
)
Functions ¶
This section is empty.
Types ¶
type BuiltinBool ¶
type BuiltinBool struct{}
Represents a cmd line argument that will be translated to a bool type.
func (BuiltinBool) Reset ¶
func (_ BuiltinBool) Reset()
type BuiltinComplex128 ¶
type BuiltinComplex128 struct{}
Represents a cmd line argument that will be translated to a complex128 type.
func (BuiltinComplex128) Reset ¶
func (_ BuiltinComplex128) Reset()
func (BuiltinComplex128) Translate ¶
func (_ BuiltinComplex128) Translate(arg string) (complex128, error)
type BuiltinComplex64 ¶
type BuiltinComplex64 struct{}
Represents a cmd line argument that will be translated to a complex64 type.
func (BuiltinComplex64) Reset ¶
func (_ BuiltinComplex64) Reset()
type BuiltinFloat32 ¶
type BuiltinFloat32 struct{}
Represents a cmd line argument that will be translated to a float32 type.
func (BuiltinFloat32) Reset ¶
func (_ BuiltinFloat32) Reset()
type BuiltinFloat64 ¶
type BuiltinFloat64 struct{}
Represents a cmd line argument that will be translated to a floa64 type.
func (BuiltinFloat64) Reset ¶
func (_ BuiltinFloat64) Reset()
type BuiltinInt ¶
type BuiltinInt struct {
Base int
}
Represents a cmd line argument that will be translated to a int type.
func (BuiltinInt) Reset ¶
func (i BuiltinInt) Reset()
type BuiltinInt16 ¶
type BuiltinInt16 struct {
Base int
}
Represents a cmd line argument that will be translated to a int16 type.
func (BuiltinInt16) Reset ¶
func (i BuiltinInt16) Reset()
type BuiltinInt32 ¶
type BuiltinInt32 struct {
Base int
}
Represents a cmd line argument that will be translated to a int32 type.
func (BuiltinInt32) Reset ¶
func (i BuiltinInt32) Reset()
type BuiltinInt64 ¶
type BuiltinInt64 struct {
Base int
}
Represents a cmd line argument that will be translated to a int64 type.
func (BuiltinInt64) Reset ¶
func (i BuiltinInt64) Reset()
type BuiltinInt8 ¶
type BuiltinInt8 struct {
Base int
}
Represents a cmd line argument that will be translated to a int8 type.
func (BuiltinInt8) Reset ¶
func (i BuiltinInt8) Reset()
type BuiltinString ¶
type BuiltinString struct{}
Represents a cmd line argument that will be translated to a string type.
func (BuiltinString) Reset ¶
func (_ BuiltinString) Reset()
type BuiltinUint ¶
type BuiltinUint struct {
Base int
}
Represents a cmd line argument that will be translated to a uint type.
func (BuiltinUint) Reset ¶
func (u BuiltinUint) Reset()
type BuiltinUint16 ¶
type BuiltinUint16 struct {
Base int
}
Represents a cmd line argument that will be translated to a uint16 type.
func (BuiltinUint16) Reset ¶
func (u BuiltinUint16) Reset()
type BuiltinUint32 ¶
type BuiltinUint32 struct {
Base int
}
Represents a cmd line argument that will be translated to a uint32 type.
func (BuiltinUint32) Reset ¶
func (u BuiltinUint32) Reset()
type BuiltinUint64 ¶
type BuiltinUint64 struct {
Base int
}
Represents a cmd line argument that will be translated to a uint64 type.
func (BuiltinUint64) Reset ¶
func (u BuiltinUint64) Reset()
type BuiltinUint8 ¶
type BuiltinUint8 struct {
Base int
}
Represents a cmd line argument that will be translated to a uint8 type.
func (BuiltinUint8) Reset ¶
func (u BuiltinUint8) Reset()
type Enum ¶ added in v0.0.2
A translator that forces a value to be a valid enum value for the given enum type.
type Flag ¶
type Flag struct{}
Used to represent a flag that can only be supplied once, returning a boolean value indicating the flags presence.
type FlagCntr ¶
Used to represent a flag that can be supplied many times, with a counter incrementing each time the flag is encountered.
type ListValues ¶
type ListValues[T any, U Translater[T], W widgets.BaseInterface[T]] struct { ValueTranslator U AllowedVals containers.HashSet[T, W] // contains filtered or unexported fields }
A translator that collects all supplied values into a slice.
func (*ListValues[T, U, W]) Reset ¶
func (l *ListValues[T, U, W]) Reset()
func (*ListValues[T, U, W]) Translate ¶
func (l *ListValues[T, U, W]) Translate(arg string) ([]T, error)
type Mkdir ¶
type Mkdir struct {
// contains filtered or unexported fields
}
A translator that makes the supplied directory along with all necessary parent directories.
func NewMkdir ¶
func NewMkdir() *Mkdir
Returns a new Mkdir struct initialized with the default values.
func (*Mkdir) GetPermissions ¶
The permissions used to create all dirs and sub-dirs. See os.MkdirAll for reference.
func (*Mkdir) SetPermissions ¶
The permissions used to create all dirs and sub-dirs. See os.MkdirAll for reference.
type Noop ¶
type Noop[T any] struct{}
Used to represent a cmd line argument that will always be the default zero-value initilized T type.
type OpenFile ¶
type OpenFile struct {
// contains filtered or unexported fields
}
A translator that makes the supplied file.
func NewOpenFile ¶
func NewOpenFile() *OpenFile
Returns a new OpenFile struct initialized with the default values.
func (*OpenFile) GetPermissions ¶
The permissions used to open the file with. See os.OpenFile for reference.
func (*OpenFile) SetPermissions ¶
The permissions used to open the file with. See os.OpenFile for reference.
type Range ¶
type Range[T basic.Number, U Translater[T]] struct { // Inclusive min Min T // Exclusive max Max T NumTranslator U }
A translator that imposes a range on the supplied cmd line argument.
type Selector ¶
type Selector[T any, U Translater[T], W widgets.BaseInterface[T]] struct { AllowedVals containers.HashSet[T, W] ValueTranslator Translater[T] }
A translator that imposes a set of specific values on a cmd line argument.
type Stopper ¶
Used to represent a flag that when encountered should stop parsing of the cmd line arguments. The error that the stopper is created with will be returned when Stopper.Translate is called.
type Translater ¶
type Translater[T any] interface { Translate(arg string) (T, error) // Resets the state of the Translater's underlying value. Reset() }
An interface that defines what actions can be performed when translating a string argument to a typed value. The translator is expected to perform all validation required to ensure a correct value is returned. It is also expected to return an error if a value is found to be invalid.