CLI/Element.pm

filter: Statementstmt 100% 17 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 100% 24 / 24 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« CLI/Argument/Number/Float.pm ↑ Summary CLI/L10N/en.pm »
1 #=============================================================================
2 #
3 # Module: Term::CLI::Element
4 #
5 # Description: Generic parent class for elements 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::Element 0.061000;
22  
23 20 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 20 ▶use Term::CLI::ReadLine;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 20 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 20 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 20 extends 'Term::CLI::Base';
32  
33 2 ▶sub complete { return () }
Subroutine complete: called CC=1 SCAR=0.0
Pod documented
34  
35 20 1;
36  
37 __END__
38  
39 =pod
40  
41 =head1 NAME
42  
43 Term::CLI::Element - generic parent class for elements in Term::CLI
44  
45 =head1 VERSION
46  
47 version 0.061000
48  
49 =head1 SYNOPSIS
50  
51 use Term::CLI::Element;
52  
53 my $arg = Term::CLI::Element->new(name => 'varname');
54  
55 =head1 DESCRIPTION
56  
57 Generic parent class for command line elements in L<Term::CLI>(3p).
58 This is used by L<Term::CLI::Command>(3p) and L<Term::CLI::Argument>(3p)
59 to provide basic, shared functionality.
60  
61 This class inherits from L<Term::CLI::Base>(3p) to provide the
62 C<error>, C<term>, and C<set_error> methods.
63  
64 =head1 CLASS STRUCTURE
65  
66 =head2 Inherits from:
67  
68 L<Term::CLI::Base>(3p).
69  
70 =head2 Consumes:
71  
72 None.
73  
74 =head1 CONSTRUCTORS
75  
76 =over
77  
78 =item B<new> ( B<name> =E<gt> I<VARNAME> ... )
79 X<new>
80  
81 Create a new Term::CLI::Element object and return a reference to it.
82  
83 The B<name> attribute is required.
84  
85 =back
86  
87 =head1 METHODS
88  
89 The C<Term::CLI::Element> class inherits accessors
90 and methods from L<Term::CLI::Base|Term::CLI::Base>(3p).
91  
92 In addition, it defines:
93  
94 =over
95  
96 =item B<complete> ( I<TEXT>, I<STATE> )
97  
98 Return a list of strings that are possible completions for I<TEXT>.
99 By default, this method returns an empty list.
100  
101 Sub-classes should probably override this.
102  
103 I<STATE> is a C<HashRef> that contains the following elements:
104  
105 =over
106  
107 =item B<processed> =E<gt> I<ArrayRef>
108  
109 More elaborate "parse tree": a list of hashes that represent all the
110 elements on the command line that have already been processed by parent
111 (C<Term::CLI::Command>) objects.
112  
113 Example:
114  
115 [
116 {
117 element => InstanceOf['Term::CLI::Command'],
118 value => 'show'
119 },
120 {
121 element => InstanceOf['Term::CLI::Command'],
122 value => 'info'
123 },
124 {
125 element => InstanceOf['Term::CLI::Argument'],
126 value => 'foo'
127 },
128 ...
129 ]
130  
131 =item B<unprocessed> =E<gt> I<ArrayRef>
132  
133 Refers to a list of words leading up to (but not including) the
134 I<TEXT> that have not yet been processed by parent objects.
135  
136 For L<Term::CLI::Command> objects this is typically a list of command
137 line arguments and sub-commands.
138  
139 For L<Term::CLI::Argument> objects this will be empty.
140  
141 =item B<options> =E<gt> I<HashRef>
142  
143 Command line options that have been seen in the input line so far.
144  
145 =back
146  
147 For most simple cases, you would only need to examine I<TEXT> (and,
148 for command objects, the C<unprocessed> list).
149  
150 The C<processed> list and C<options> hash can be used to implement context
151 sensitive completion, however.
152  
153 =back
154  
155 =head1 SEE ALSO
156  
157 L<Term::CLI::Argument|Term::CLI::Argument>(3p),
158 L<Term::CLI::Base|Term::CLI::Base>(3p),
159 L<Term::CLI::Command|Term::CLI::Command>(3p),
160 L<Term::CLI::ReadLine|Term::CLI::ReadLine>(3p),
161 L<Term::CLI|Term::CLI>(3p).
162  
163 =head1 AUTHOR
164  
165 Steven Bakker E<lt>sbakker@cpan.orgE<gt>, 2018.
166  
167 =head1 COPYRIGHT AND LICENSE
168  
169 Copyright (c) 2018 Steven Bakker
170  
171 This module is free software; you can redistribute it and/or modify
172 it under the same terms as Perl itself. See "perldoc perlartistic."
173  
174 This software is distributed in the hope that it will be useful,
175 but WITHOUT ANY WARRANTY; without even the implied warranty of
176 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
177  
178 =cut
« CLI/Argument/Number/Float.pm ↑ Summary CLI/L10N/en.pm »