| 1 | package Lim::Component::CLI; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use common::sense; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 1 | ▶ | use Log::Log4perl (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 1 | ▶ | use Lim (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | =encoding utf8 | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | ... | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | =head1 VERSION | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | See L<Lim> for version. | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | =cut | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 1 | our $VERSION = $Lim::VERSION; | |||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | =head1 SYNOPSIS | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | ... | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | =head2 new | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | =cut | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||
| 36 | 0 | my $this = shift; | |||||||||||||||||||
| 37 | 0 | ▶ | my $class = ref($this) || $this; | ||||||||||||||||||
|
Condition0%0/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table0%0/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||
| 38 | 0 | my %args = ( @_ ); | |||||||||||||||||||
| 39 | 0 | my $self = { | |||||||||||||||||||
| 40 | logger => Log::Log4perl->get_logger($class), | ||||||||||||||||||||
| 41 | }; | ||||||||||||||||||||
| 42 | 0 | bless $self, $class; | |||||||||||||||||||
| 43 | 0 | weaken($self->{logger}); | |||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 0 | ▶ | unless (defined $args{cli}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 46 | 0 | confess __PACKAGE__, ': Missing cli'; | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | 0 | $self->{cli} = delete $args{cli}; | |||||||||||||||||||
| 49 | 0 | weaken($self->{cli}); | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | eval { | |||||||||||||||||||
| 52 | 0 | $self->Init(%args); | |||||||||||||||||||
| 53 | }; | ||||||||||||||||||||
| 54 | 0 | ▶ | if ($@) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Unable to initialize module '.$class.': '.$@); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 56 | 0 | return; | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 0 | ▶ | Lim::OBJ_DEBUG and $self->{logger}->debug('new ', __PACKAGE__, ' ', $self); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 60 | 0 | $self; | |||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||
|
Subroutine
DESTROY: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 64 | 0 | my ($self) = @_; | |||||||||||||||||||
| 65 | 0 | ▶ | Lim::OBJ_DEBUG and $self->{logger}->debug('destroy ', __PACKAGE__, ' ', $self); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | $self->Destroy; | |||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | =head2 Init | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | =cut | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 0 | ▶ | sub Init { | ||||||||||||||||||
|
Subroutine
Init: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | =head2 Destroy | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | =cut | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | 0 | ▶ | sub Destroy { | ||||||||||||||||||
|
Subroutine
Destroy: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | =head2 cli | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | =cut | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 0 | ▶ | sub cli { | ||||||||||||||||||
|
Subroutine
cli: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 89 | 0 | $_[0]->{cli}; | |||||||||||||||||||
| 90 | } | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | =head2 Prompt | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | =cut | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 0 | ▶ | sub Prompt { | ||||||||||||||||||
|
Subroutine
Prompt: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 97 | 0 | my ($self) = @_; | |||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | 0 | ▶ | if (ref($self)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 100 | 0 | $self = ref($self); | |||||||||||||||||||
| 101 | } | ||||||||||||||||||||
| 102 | 0 | $self =~ s/::[^:]+$//o; | |||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | 0 | return '/'.lc($self->Name); | |||||||||||||||||||
| 105 | } | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | =head2 Successful | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | =cut | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | 0 | ▶ | sub Successful { | ||||||||||||||||||
|
Subroutine
Successful: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 112 | 0 | my ($self) = @_; | |||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | 0 | ▶ | if (defined $self->{cli}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 115 | 0 | $self->{cli}->Successful; | |||||||||||||||||||
| 116 | } | ||||||||||||||||||||
| 117 | } | ||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | =head2 Error | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | =cut | ||||||||||||||||||||
| 122 | |||||||||||||||||||||
| 123 | 0 | ▶ | sub Error { | ||||||||||||||||||
|
Subroutine
Error: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 124 | 0 | my $self = shift; | |||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | 0 | ▶ | if (defined $self->{cli}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 127 | 0 | $self->{cli}->Error(@_); | |||||||||||||||||||
| 128 | } | ||||||||||||||||||||
| 129 | else { | ||||||||||||||||||||
| 130 | 0 | ▶ | Lim::ERR and $self->{logger}->error('Command returned error but CLI is gone [', $self, ']'); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 131 | } | ||||||||||||||||||||
| 132 | } | ||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | =head1 AUTHOR | ||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | Jerry Lundström, C<< <lundstrom.jerry at gmail.com> >> | ||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | =head1 BUGS | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | Please report any bugs or feature requests to L<https://github.com/jelu/lim/issues>. | ||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | =head1 SUPPORT | ||||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | perldoc Lim | ||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | You can also look for information at: | ||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | =over 4 | ||||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | =item * Lim issue tracker (report bugs here) | ||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | L<https://github.com/jelu/lim/issues> | ||||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | =back | ||||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||
| 161 | |||||||||||||||||||||
| 162 | Copyright 2012-2013 Jerry Lundström. | ||||||||||||||||||||
| 163 | |||||||||||||||||||||
| 164 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||
| 165 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||
| 166 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||
| 167 | |||||||||||||||||||||
| 168 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||
| 169 | |||||||||||||||||||||
| 170 | |||||||||||||||||||||
| 171 | =cut | ||||||||||||||||||||
| 172 | |||||||||||||||||||||
| 173 | 1 | 1; # End of Lim::Component::CLI | |||||||||||||||||||