CLI/Base.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 4 / 4 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 11 / 11 Podpod 100% 4 / 4 totaltotal 100% 60 / 60 CC 4 SCAR 4.5
CC
4
Cov
100%
set_error
3.0
root_node
2.0
BEGIN
1.0
CRAP 1.6
« CLI/Argument.pm ↑ Summary CLI/Argument/Number/Int.pm »
1 #=============================================================================
2 #
3 # Module: Term::CLI::Base
4 #
5 # Description: Generic base class for Term::CLI classes
6 #
7 # Author: Steven Bakker (SBAKKER), <cpanman@monkey-mind.net>
8 # Created: 10/02/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::Base 0.061001;
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 Types::Standard 1.000005 qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
29 Str
30 Maybe InstanceOf
31 20 );
32  
33 20 ▶use Moo 1.000001;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 20 ▶use namespace::clean 0.25;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 20 has name => ( is => 'ro', isa => Str, required => 1 );
37 104 ▶has error => ( is => 'rwp', isa => Str, default => sub {q{}} );
Subroutine __ANON__: called CC=1 SCAR=0.0
38  
39 20 has parent => (
40 is => 'rwp',
41 week_ref => 1,
42 isa => Maybe[ InstanceOf['Term::CLI::Element'] ],
43 );
44  
45 241 ▶sub root_node {
Subroutine root_node: called CC=2 SCAR=6.9
Pod documented
46 241 my ($self) = my ($curr_node) = @_;
47  
48 241 ▶ while ( my $parent = $curr_node->parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $curr_node->parent) 6 241 247
49 6 $curr_node = $parent;
50 }
51 241 return $curr_node;
52 }
53  
54 127 ▶sub term { return Term::CLI::ReadLine->term }
Subroutine term: called CC=1 SCAR=0.0
Pod documented
55  
56 82 ▶sub clear_error {
Subroutine clear_error: called CC=1 SCAR=0.0
Pod documented
57 82 my ($self) = @_;
58 82 $self->_set_error(q{});
59 82 return 1;
60 }
61  
62 78 ▶sub set_error {
Subroutine set_error: called CC=3 SCAR=11.0
Pod documented
63 78 my ( $self, @value ) = @_;
64 78 ▶ if ( !@value || !defined $value[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@value and defined $value[0]) 2 76 78
Condition100%3/3
@value and defined $value[0]
!ll&&!rl&&r
1176
MC/DC100%2/2
@value and defined $value[0]
@value defined $value[0]
Truth table100%3/3
A and B
A= @valueB= defined $value[0]
ABresult
0X0
100
111
65 2 $self->clear_error(q{});
66 return
67 2 }
68 76 $self->_set_error( join( q{}, @value ) );
69 76 return;
70 }
71  
72 20 1;
73  
74 __END__
« CLI/Argument.pm ↑ Summary CLI/Argument/Number/Int.pm »