| 1 | #============================================================================= | ||||||||||
| 2 | # | ||||||||||
| 3 | # Module: Term::CLI::Argument::Number::Int | ||||||||||
| 4 | # | ||||||||||
| 5 | # Description: Class for integer arguments in Term::CLI | ||||||||||
| 6 | # | ||||||||||
| 7 | # Author: Steven Bakker (SBAKKER), <sbakker@cpan.org> | ||||||||||
| 8 | # Created: 22/01/18 | ||||||||||
| 9 | # | ||||||||||
| 10 | # Copyright (c) 2018-2022 Steven Bakker | ||||||||||
| 11 | # | ||||||||||
| 12 | # This module is free software; you can redistribute it and/or modify | ||||||||||
| 13 | # it under the same terms as Perl itself. See "perldoc perlartistic." | ||||||||||
| 14 | # | ||||||||||
| 15 | # This software is distributed in the hope that it will be useful, | ||||||||||
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||
| 18 | # | ||||||||||
| 19 | #============================================================================= | ||||||||||
| 20 | |||||||||||
| 21 | package Term::CLI::Argument::Number::Int 0.061000; | ||||||||||
| 22 | |||||||||||
| 23 | 7 | ▶ | use 5.014; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 7 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 7 | ▶ | use Moo 1.000001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 7 | ▶ | use namespace::clean 0.25; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | |||||||||||
| 29 | 7 | extends 'Term::CLI::Argument::Number'; | |||||||||
| 30 | |||||||||||
| 31 | sub coerce_value { | ||||||||||
| 32 | 18 | ▶ | my ( $self, $val ) = @_; | ||||||||
|
Subroutine
coerce_value: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 33 | |||||||||||
| 34 | 18 | ▶ | if ( $val =~ /^ [+-]? \d+ $/xsm ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 17 | return int($val); | |||||||||
| 36 | } | ||||||||||
| 37 | ## no critic (ProhibitExplicitReturnUndef) | ||||||||||
| 38 | 1 | return undef; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 7 | 1; | |||||||||
| 42 | |||||||||||
| 43 | __END__ | ||||||||||
| 44 | |||||||||||
| 45 | =pod | ||||||||||
| 46 | |||||||||||
| 47 | =head1 NAME | ||||||||||
| 48 | |||||||||||
| 49 | Term::CLI::Argument::Number::Int - class for integer arguments in Term::CLI | ||||||||||
| 50 | |||||||||||
| 51 | =head1 VERSION | ||||||||||
| 52 | |||||||||||
| 53 | version 0.061000 | ||||||||||
| 54 | |||||||||||
| 55 | =head1 SYNOPSIS | ||||||||||
| 56 | |||||||||||
| 57 | use Term::CLI::Argument::Number::Int; | ||||||||||
| 58 | |||||||||||
| 59 | my $arg = Term::CLI::Argument::Number::Int->new( | ||||||||||
| 60 | name => 'count', | ||||||||||
| 61 | min => 0, | ||||||||||
| 62 | max => 100_000, | ||||||||||
| 63 | inclusive => 1 | ||||||||||
| 64 | ); | ||||||||||
| 65 | |||||||||||
| 66 | =head1 DESCRIPTION | ||||||||||
| 67 | |||||||||||
| 68 | Class for integer arguments in L<Term::CLI>(3p). Extends | ||||||||||
| 69 | L<Term::CLI::Argument::Number>(3p). | ||||||||||
| 70 | |||||||||||
| 71 | =head2 Inherits from: | ||||||||||
| 72 | |||||||||||
| 73 | L<Term::CLI::Argument::Number>(3p). | ||||||||||
| 74 | |||||||||||
| 75 | =head2 Consumes: | ||||||||||
| 76 | |||||||||||
| 77 | None. | ||||||||||
| 78 | |||||||||||
| 79 | =head1 CONSTRUCTORS | ||||||||||
| 80 | |||||||||||
| 81 | See L<Term::CLI::Argument::Number>(3p). | ||||||||||
| 82 | |||||||||||
| 83 | =head1 ACCESSORS | ||||||||||
| 84 | |||||||||||
| 85 | See L<Term::CLI::Argument::Number>(3p). | ||||||||||
| 86 | |||||||||||
| 87 | =head1 METHODS | ||||||||||
| 88 | |||||||||||
| 89 | Inherited from | ||||||||||
| 90 | L<Term::CLI::Argument::Number>(3p). | ||||||||||
| 91 | |||||||||||
| 92 | Additionally: | ||||||||||
| 93 | |||||||||||
| 94 | =over | ||||||||||
| 95 | |||||||||||
| 96 | =item B<coerce_value> ( I<VALUE> ) | ||||||||||
| 97 | |||||||||||
| 98 | Overloaded to check for a valid integer value. | ||||||||||
| 99 | |||||||||||
| 100 | =back | ||||||||||
| 101 | |||||||||||
| 102 | =head1 SEE ALSO | ||||||||||
| 103 | |||||||||||
| 104 | L<Term::CLI::Argument::Number::Float>(3p), | ||||||||||
| 105 | L<Term::CLI::Argument::Number>(3p), | ||||||||||
| 106 | L<Term::CLI::Argument>(3p), | ||||||||||
| 107 | L<Term::CLI>(3p). | ||||||||||
| 108 | |||||||||||
| 109 | =head1 AUTHOR | ||||||||||
| 110 | |||||||||||
| 111 | Steven Bakker E<lt>sbakker@cpan.orgE<gt>, 2018. | ||||||||||
| 112 | |||||||||||
| 113 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 114 | |||||||||||
| 115 | Copyright (c) 2018 Steven Bakker | ||||||||||
| 116 | |||||||||||
| 117 | This module is free software; you can redistribute it and/or modify | ||||||||||
| 118 | it under the same terms as Perl itself. See "perldoc perlartistic." | ||||||||||
| 119 | |||||||||||
| 120 | This software is distributed in the hope that it will be useful, | ||||||||||
| 121 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||
| 122 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||
| 123 | |||||||||||
| 124 | =cut | ||||||||||