++ed by:
ESAYM JEFFOBER SBAKKER

3 PAUSE users

Steven Bakker

NAME

Term::CLI::Argument - generic parent class for arguments in Term::CLI

VERSION

version 0.04007

SYNOPSIS

 use Term::CLI::Argument;

 my $arg = Term::CLI::Argument->new(name => 'varname');

DESCRIPTION

Generic parent class for arguments in Term::CLI(3p). Inherits from M6::CLI::Element(3p).

CLASS STRUCTURE

Inherits from:

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

Consumes:

None.

CONSTRUCTORS

new ( name => VARNAME ... )

Create a new Term::CLI::Argument object and return a reference to it.

The name attribute is required.

Other possible attributes are:

min_occur => INT

The minimal number of times the argument must occur. A negative or zero value means there is no minimum.

The default is 1.

max_occur => INT

The maximum number of times the argument may occur. A negative or zero value means there is no maximum.

The default is 1.

occur => INT

A shortcut to setting min_occur and max_occur to the same value. Specifying this will override any min_occur or max_occur attributes.

METHODS

Accessors

Accessors are inherited from Term::CLI::Element(3p).

Additionally, there are the following:

min_occur ( [ INT ] )

Get or set the min_occur attribute.

max_occur ( [ INT ] )

Get or set the max_occur attribute.

Other

occur ( [ INT [, INT ] ] )

When called with no arguments, returns two-element list containing the min_occur and max_occur values, resp.

When called with one argument, it will set both the min_occur and max_occur attributes to the given value.

type

Return the argument "type". By default, this is the object's class name with the M6::CLI::Argument:: prefix removed. Can be overloaded to provide a different value.

validate ( value )

Check whether value is a valid value for this object. Return the (possibly normalised) value if it is, nothing (i.e. undef or the empty list, depending on call context) if it is not (and set the error() attribute).

By default, this method only checks whether value is defined and not an empty string.

Sub-classes should probably override this.

SEE ALSO

Term::CLI::Argument::String(3p), Term::CLI::Argument::Number(3p), Term::CLI::Argument::Enum(3p), Term::CLI::Argument::Filename(3p), Term::CLI::Element(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.