NAME

Term::CLI::Argument::String - class for basic string arguments in Term::CLI

VERSION

version 0.059000

SYNOPSIS

use Term::CLI::Argument::String;

my $arg1 = Term::CLI::Argument::String->new(
   name => 'arg1'
);

$arg1->validate('');      # returns ''
$arg1->validate('a');     # returns 'a'
$arg1->validate('abcde'); # returns 'abcde'

my $arg2 = Term::CLI::Argument::String->new(
   name => 'arg2'
   min_length => 1,
   max_length => 4,
);

$arg2->validate('');      # returns undef, sets error
$arg2->validate('a');     # returns 'a'
$arg2->validate('abcde'); # returns undef, sets error

DESCRIPTION

Simple class for string arguments in Term::CLI(3p). This is basically the Term::CLI::Argument(3p) class, but also allowing empty strings.

CLASS STRUCTURE

Inherits from:

Term::CLI::Argument(3p).

Consumes:

None.

CONSTRUCTORS

See Term::CLI::Argument(3p). Additional attributes are:

min_len => NUM

The minimum required length for any value.

max_len => NUM

The maximum lenght allowed for any value.

ACCESSORS

Inherited from Term::CLI::Argument(3p). Additionally, the following are defined:

min_len ( NUMBER )
max_len ( NUMBER )

Minimum and maximum length for the string, resp.

has_min_len
has_max_len

Booleans, indicate whether min_len and max_len have been set, resp.

clear_min_len
clear_max_len

Clear the min_len and max_len limits, resp.

See Term::CLI::Argument(3p).

METHODS

See Term::CLI::Argument(3p).

validate ( Str )

Overloaded from Term::CLI::Argument.

Requires the Str value to be defined, and have a length that is between min_len and max_len (if defined).

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.