Term::CLI::Element - generic parent class for elements in Term::CLI
version 0.059000
use Term::CLI::Element; my $arg = Term::CLI::Element->new(name => 'varname');
Generic parent class for command line elements in Term::CLI(3p). This is used by Term::CLI::Command(3p) and Term::CLI::Argument(3p) to provide basic, shared functionality.
This class inherits from Term::CLI::Base(3p) to provide the error, term, and set_error methods.
error
term
set_error
Term::CLI::Base(3p).
None.
Create a new Term::CLI::Element object and return a reference to it.
The name attribute is required.
The Term::CLI::Element class inherits accessors and methods from Term::CLI::Base(3p).
Term::CLI::Element
In addition, it defines:
Return a list of strings that are possible completions for TEXT. By default, this method returns an empty list.
Sub-classes should probably override this.
STATE is a HashRef that contains the following elements:
HashRef
More elaborate "parse tree": a list of hashes that represent all the elements on the command line that have already been processed by parent (Term::CLI::Command) objects.
Term::CLI::Command
Example:
[ { element => InstanceOf['Term::CLI::Command'], value => 'show' }, { element => InstanceOf['Term::CLI::Command'], value => 'info' }, { element => InstanceOf['Term::CLI::Argument'], value => 'foo' }, ... ]
Refers to a list of words leading up to (but not including) the TEXT that have not yet been processed by parent objects.
For Term::CLI::Command objects this is typically a list of command line arguments and sub-commands.
For Term::CLI::Argument objects this will be empty.
Command line options that have been seen in the input line so far.
For most simple cases, you would only need to examine TEXT (and, for command objects, the unprocessed list).
unprocessed
The processed list and options hash can be used to implement context sensitive completion, however.
processed
options
Term::CLI::Argument(3p), Term::CLI::Base(3p), Term::CLI::Command(3p), Term::CLI::ReadLine(3p), Term::CLI(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.