Documentation ¶
Overview ¶
Package unitsetter provides a type which satisfies the param Setter interface and can be used to set a units.Unit element through the command line.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UnitCheckFunc ¶
UnitCheckFunc is the type of the check function for this setter. It takes a Unit parameter and returns an error (or nil)
type UnitSetter ¶
type UnitSetter struct { psetter.ValueReqMandatory Value *units.Unit UD units.UnitDetails Checks []UnitCheckFunc ValDesc string }
UnitSetter allows you to specify a parameter that can be used to set a Unit value. You can also supply check functions that will validate the Value.
If you give a ValDesc then that is used as the value description in the help message, otherwise the Unit Family description is used (with spaces replaced by dashes)
func (UnitSetter) AllowedValues ¶
func (s UnitSetter) AllowedValues() string
AllowedValues returns a string describing the allowed values
func (UnitSetter) CheckSetter ¶
func (s UnitSetter) CheckSetter(name string)
CheckSetter panics if the setter has not been properly created - if the Value is nil, if the base unit is invalid or if one of the check functions is nil.
func (UnitSetter) CountChecks ¶
func (s UnitSetter) CountChecks() int
CountChecks returns the number of check functions
func (UnitSetter) CurrentValue ¶
func (s UnitSetter) CurrentValue() string
CurrentValue returns the current setting of the parameter value
func (UnitSetter) SetWithVal ¶
func (s UnitSetter) SetWithVal(_ string, paramVal string) error
SetWithVal (called when a value follows the parameter) checks that the value can be found in the map of Units, if it cannot it returns an error. If there are checks and any check is violated it returns an error. Only if the value is parsed successfully and no checks are violated is the Value set.
func (UnitSetter) ValDescribe ¶ added in v3.1.0
func (s UnitSetter) ValDescribe() string
ValDescribe returns a string describing the value that can follow the parameter