recline.arg_types.ranged_int module
Original © NetApp 2024
A RangedInt type allows the CLI command writer to specify an integer that is only valid within a certain range. If the user provides a value outside of that range, then the parameter validation will fail and they will receive an error message.
@recline.command(name=”bake cake”) def bake(minutes: RangedInt.define(min=15, max=60)) -> None:
# If the user tried to bake the cake for less than 15 minutes or more than # 60 minutes, then this body wouldn’t be called and they would get an error.
- class recline.arg_types.ranged_int.RangedInt
Bases:
ReclineType
The RangedInt type allows a parameter which is an into to be constrained in which values are in the valid range.
- static define(min: int = None, max: int = None) _RangedInt
A recline.commands.types.RangedInt is a way to annotate an integer with a min and max value.
Prior to being passed to your command, the arguments of this type will be validated according to the parameters specified. For example, if a minimum is given, then the argument must be less than the minimum before your command will be called with it.
- Args:
- name: This is the name of the parameter and is required for building
the help text of the command.
- min: If provided, the user-supplied argument will be validated to be
and integer >= this value. argument will be enforced.
- max: If provided, the user-supplied argument will be validated to be
and integer <= this value.