Term::CLI::Role::ArgumentSet - Role for (sub-)commands in Term::CLI
version 0.04005
package Term::CLI::Command { use Moo; with('Term::CLI::Role::ArgumentSet'); ... }; my $cmd = Term::CLI::Command->new( ... ); $cmd->add_argument( Term::CLI::Argument->new(...) ); say "argument names:", join(', ', $cmd->argument_names);
Role for Term::CLI::Command(3p) elements to represent a set of Term::CLI::Argument(3p) objects.
This role is consumed by Term::CLI::Command(3p).
This role defines two additional attributes:
Reference to an array containing Term::CLI::Argument object instances that describe the parameters that the command takes, or undef.
Term::CLI::Argument
undef
Note that the elements of the array are copied over to an internal array, so modifications to the ArrayRef will not be seen.
Predicate function that returns whether or not any Term::CLI::Arguments have been added.
Return the list of Term::CLI::Argument object references that are owned by this object.
Reset the list of arguments to (ARG, ...). Each ARG should be a reference to a Term::CLI::Argument object.
Add ARG(s) to the argument set. Each ARG should be a reference to a Term::CLI::Argument object.
Return the list of (sub-)command names (in the order they were specified).
Return a list of all commands in this object that match the Str prefix.
Check whether Str uniquely matches a command in this Term::CLI object. Returns a reference to the appropriate Term::CLI::Command object if successful; otherwise, it sets the objects error field and returns undef.
Term::CLI
error
Example:
my $sub_cmd = $cmd->find_command($prefix); die $cmd->error unless $sub_cmd;
Wrapper function that will call the object's callback function if it has been set, otherwise simply returns its arguments.
callback
Term::CLI(3p), Term::CLI::Command(3p).
Steven Bakker <sbakker@cpan.org>, 2018.
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.
To install Term::CLI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Term::CLI
CPAN shell
perl -MCPAN -e shell install Term::CLI
For more information on module installation, please visit the detailed CPAN module installation guide.