lib/Devel/Trepan/CmdProcessor/Help.pm

filter: Statementstmt 22.9% 11 / 48 Branchbran 7.1% 1 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 27.2% 3 / 11 Podpod 0.0% 0 / 8 totaltotal 16.4% 15 / 91 CC 11 SCAR 23.3
CC
11
Cov
18%
summary_help
20.0
summary_help
20.0
summary_list
6.0
CRAP 10.2
« blib/lib/Devel/Trepan/CmdProcessor/Command/Set_Subcmd/Display_Subcmd/Eval.pm ↑ Summary lib/Devel/Trepan/CmdProcessor/Command/Eval.pm »
1 # Copyright (C) 2011-2012 Rocky Bernstein <rocky@cpan.org>
2 # -*- coding: utf-8 -*-
3 12 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 12 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 package Devel::Trepan::CmdProcessor;
8  
9 0 ▶sub abbrev_stringify($$$) {
Subroutine abbrev_stringify: not called CC=1 SCAR=6.9
Pod undocumented
10 0 ▶ my ($self, $name, $min_abbrev) = @_;
Subroutine abbrev_stringify: not called CC=1 SCAR=6.9
Pod undocumented
11 0 sprintf "(%s)%s", substr($name, 0, $min_abbrev), substr($name, $min_abbrev);
12 }
13  
14 # Return constant SHORT_HELP or build it from HELP
15 0 ▶sub summary_help($$) {
Subroutine summary_help: not called CC=4 SCAR=30.0
Pod undocumented
16 0 ▶ my ($self, $subcmd) = @_;
Subroutine summary_help: not called CC=4 SCAR=30.0
Pod undocumented
17 0 my $short_help;
18 0 ▶ if (defined $subcmd->{help} && !defined $subcmd->{short_help}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $subcmd->{'help'} and not defined $subcmd->{'short_help'}) { } 0 0 0
if (defined $subcmd->{'help'} and not defined $subcmd->{'short_help'}) { } 0 0 0
Condition0%0/6
defined $subcmd->{"help"} and not defined $subcmd->{"short_help"}
!ll&&!rl&&r
000
defined $subcmd->{"help"} and not defined $subcmd->{"short_help"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $subcmd->{"help"} and not defined $subcmd->{"short_help"}
defined $subcmd->{"help"} not defined $subcmd->{"short_help"}
MC/DC0%0/2
defined $subcmd->{"help"} and not defined $subcmd->{"short_help"}
defined $subcmd->{"help"} not defined $subcmd->{"short_help"}
Truth table0%0/3
A and not(B)
A= defined $subcmd->{"help"}B= not defined $subcmd->{"short_help"}
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= defined $subcmd->{"help"}B= not defined $subcmd->{"short_help"}
ABresult
0X0
100
111
19 0 my @lines = split("\n", $subcmd->{help});
20 0 $short_help = $lines[0];
21 0 ▶ $short_help = substr($short_help, 0, -1) if
Branch: 2 branches
BranchTrueFalseTotal
if "." eq substr($short_help, -1, 1) 0 0 0
if "." eq substr($short_help, -1, 1) 0 0 0
22 '.' eq substr($short_help, -1, 1);
23 } else {
24 0 $short_help = $subcmd->{short_help};
25 }
26  
27 sprintf(' %-13s -- %s',
28 $self->abbrev_stringify($subcmd->{name},
29 0 $subcmd->{min_abbrev}),
30 $short_help);
31 }
32  
33 # We were given cmd without a subcommand; cmd is something
34 # like "show", "info" or "set". Generally this means list
35 # all of the subcommands.
36 0 ▶sub summary_list($$$) {
Subroutine summary_list: not called CC=2 SCAR=17.9
Pod undocumented
37 0 ▶ my ($self, $name, $subcmds) = @_;
Subroutine summary_list: not called CC=2 SCAR=17.9
Pod undocumented
38 0 $self->section("List of ${name} commands (with minimum abbreviation in parenthesis):");
39 0 foreach my $subcmd_name (sort keys %{$subcmds}) {
40 # Some commands have lots of output.
41 # they are excluded here because 'in_list' is false.
42 0 $self->msg($self->summary_help($subcmds->{$subcmd_name}));
43 }
44 }
45  
46 # Error message when subcommand asked for but doesn't exist
47 0 ▶sub undefined_subcmd($$$) {
Subroutine undefined_subcmd: not called CC=2 SCAR=17.9
Pod undocumented
48 0 ▶ my ($self, $cmd, $subcmd) = @_;
Subroutine undefined_subcmd: not called CC=2 SCAR=17.9
Pod undocumented
49 0 ▶ my $ambig = $self->{settings}->{abbrev} ? 'or ambiguous ' : '';
Branch: 2 branches
BranchTrueFalseTotal
$self->{'settings'}{'abbrev'} ? : 0 0 0
$self->{'settings'}{'abbrev'} ? : 0 0 0
50 0 $self->errmsg([sprintf('Undefined %s"%s" subcommand: "%s". ', $ambig, $cmd, $subcmd),
51 sprintf('Try "help %s *".', $cmd)]);
52 }
53  
54 12 ▶if (__FILE__ eq $0) {
Branch: 1 branch
BranchTrueFalseTotal
if (__FILE__ eq $0) 0 12 12
55 0 print abbrev_stringify('bogus-class', 'foo-command', 3), "\n";
56 }
57 12 1;
« blib/lib/Devel/Trepan/CmdProcessor/Command/Set_Subcmd/Display_Subcmd/Eval.pm ↑ Summary lib/Devel/Trepan/CmdProcessor/Command/Eval.pm »