lib/Devel/Trepan/CmdProcessor/Command/Unalias.pm

filter: Statementstmt 65.7% 71 / 108 Branchbran 37.5% 3 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 79.1% 19 / 24 Podpod 0.0% 0 / 5 totaltotal 64.1% 93 / 145 CC 7 SCAR 9.0
CC
7
Cov
64%
run
5.7
run
5.7
run
5.7
CRAP 2.5
« blib/lib/Devel/Trepan/CmdProcessor/Mock.pm ↑ Summary lib/Devel/Trepan/CmdProcessor/Command/Up.pm »
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-2012, 2014 Rocky Bernstein <rocky@cpan.org>
3  
4 12 ▶use warnings; no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use rlib '../../../..';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 package Devel::Trepan::CmdProcessor::Command::Unalias;
8 12 ▶use if !@ISA, Devel::Trepan::CmdProcessor::Command ;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶unless (@ISA) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@ISA) 0 12 12
11 0 ▶ eval <<'EOE';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
12 use constant CATEGORY => 'support';
13 use constant SHORT_HELP => 'Remove an alias';
14 use constant MIN_ARGS => 0; # Need at least this many
15 use constant MAX_ARGS => undef; # Need at most this many - undef -> unlimited.
16 use constant NEED_STACK => 0;
17 EOE
18 }
19  
20 12 ▶use strict; use vars qw(@ISA); @ISA = @CMD_ISA;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
21 12 ▶use vars @CMD_VARS; # Value inherited from parent
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 our $NAME = set_name();
24 =pod
25  
26 =head2 Synopsis:
27  
28 =cut
29 1 our $HELP = <<'HELP';
30 =pod
31  
32 B<unalias> I<alias1> [I<alias2> ...]
33  
34 Remove alias I<alias1> and so on.
35  
36 =head2 Example:
37  
38 unalias s # Remove 's' as an alias for 'step'
39  
40 =head2 See also:
41  
42 L<C<alias>|Devel::Trepan::CmdProcessor::Command::Alias>, and
43 L<C<show aliases>|Devel::Trepan::CmdProcessor::Command::Show::Aliases>.
44  
45 =cut
46 HELP
47  
48 1 our $ARGS = 1;
49  
50 sub complete($$)
51 0 ▶{
Subroutine complete: not called CC=1 SCAR=6.9
Subroutine complete: not called CC=1 SCAR=6.9
Pod undocumented
Pod undocumented
52 0 ▶ my ($self, $prefix) = @_;
Subroutine complete: not called CC=1 SCAR=6.9
Pod undocumented
53 0 my $proc = $self->{proc};
54 0 my @candidates = keys %{$proc->{aliases}};
55 0 my @matches =
56 Devel::Trepan::Complete::complete_token(\@candidates, $prefix);
57 0 sort @matches;
58 }
59  
60 # Run command.
61 0 ▶sub run($$) {
Subroutine run: not called CC=3 SCAR=17.3
Subroutine run: not called CC=3 SCAR=17.3
Pod undocumented
Pod undocumented
62 0 my ($self, $args) = @_;
63 0 my $proc = $self->{proc};
64 0 my @args = @$args; shift @args;
65 0 for my $arg (@args) {
66 0 ▶ if (exists $proc->{aliases}{$arg}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $proc->{'aliases'}{$arg}) { } 0 0 0
if (exists $proc->{'aliases'}{$arg}) { } 11 0 11
67 0 my $command_name = $proc->{aliases}{$arg};
68 0 $proc->remove_alias($command_name, $arg);
69 0 $proc->msg("Alias for ${arg} removed.");
70 } else {
71 0 $proc->msg("No alias found for ${arg}.");
72 }
73 }
74 }
75  
76 1 ▶unless (caller) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller) 0 1 1
77 # Demo it.
78 0 require Devel::Trepan::CmdProcessor::Mock;
79 0 my $proc = Devel::Trepan::CmdProcessor::Mock::setup();
80 0 my $cmd = __PACKAGE__->new($proc);
81 0 $cmd->run([$NAME, 's']);
82 0 $cmd->run([$NAME, 's']);
83 }
84  
85 1 1;
« blib/lib/Devel/Trepan/CmdProcessor/Mock.pm ↑ Summary lib/Devel/Trepan/CmdProcessor/Command/Up.pm »