NAME
Term::CLI::Argument::Number - base class for numerical arguments in Term::CLI
VERSION
version 0.060000
SYNOPSIS
use Term::CLI::Argument::Number;
my $arg = Term::CLI::Argument::Number->new(
name => 'arg1',
min => 1
max => 2
inclusive => 1
);
DESCRIPTION
Base class for numerical arguments in Term::CLI(3p). This class cannot be used directly, but should be extended by sub-classes.
CLASS STRUCTURE
Inherits from:
Term::CLI::Argument(3p).
Consumes:
None.
CONSTRUCTORS
- new ( name => VARNAME, ... )
-
Create a new Term::CLI::Argument::Number object and return a reference to it.
The name attribute is required.
Other attributes that are recognised:
- min => NUM
-
The minimum valid value (by default an inclusive boundary, but see inclusive below.
- max => NUM
-
The maximum valid value (by default an inclusive boundary, but see inclusive below.
- inclusive => BOOLEAN
-
Default is 1 (true). Indicates whether minimum/maximum boundaries are inclusive or exclusive.
ACCESSORS
Inherited from Term::CLI::Argument(3p). Additionally, the following are defined:
- min ( NUMBER )
- max ( NUMBER )
-
Lower and upper boundaries, resp.
- inclusive ( BOOL )
-
Boolean indicating whether the boundaries are inclusive.
- has_min
- has_max
-
Booleans, indicate whether
min
andmax
have been set, resp. - clear_min
- clear_max
-
Clear the
min
andmax
limits, resp.
METHODS
Inherited from Term::CLI::Argument(3p).
Additionally:
- validate ( VALUE )
-
The validate method uses the coerce_value method to convert VALUE to a suitable number and then checks any boundaries.
- coerce_value ( VALUE )
-
This method must be overridden by sub-classes.
It will be called with a single argument (the VALUE) and is supposed to return the converted number. If the number is not valid, it should return
undef
.
SEE ALSO
Term::CLI::Argument(3p), Term::CLI(3p).
AUTHOR
Steven Bakker <sbakker@cpan.org>, 2018.
COPYRIGHT AND LICENSE
Copyright (c) 2018 Steven Bakker
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See "perldoc perlartistic."
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.