blib/lib/Getopt/Kingpin/Command.pm

filter: Statementstmt 100% 44 / 44 Branchbran 100% 14 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 100% 67 / 67 SCAR 23.0
CC
10
Cov
100%
help
6.0
help_short
5.0
BEGIN
1.0
CRAP 10.0
« blib/lib/Getopt/Kingpin/Flag.pm ↑ Summary blib/lib/Getopt/Kingpin/Args.pm »
1 package Getopt::Kingpin::Command;
2 31 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 31 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 31 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 31 ▶use Getopt::Kingpin -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 31 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 31 our $VERSION = "0.10";
9  
10 sub help_short {
11 34 ▶ my $self = shift;
Subroutine help_short: called CC=5 SCAR=16.1
Pod documented
12 34 my @help = ($self->name);
13  
14 34 ▶ if ($self->name eq "help") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->name eq 'help') { } 6 28 34
15 6 push @help, "[<command>...]";
16 } else {
17 28 ▶ if ($self->flags->count > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->flags->count > 1) 18 10 28
18 18 push @help, "[<flags>]";
19 }
20  
21 28 ▶ if ($self->commands->count > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->commands->count > 0) { } 1 27 28
22 1 push @help, "<command>";
23 1 push @help, "[<args> ...]";
24 } else {
25 27 foreach my $arg ($self->args->get_all) {
26 24 push @help, $arg->help_name(1);
27 }
28 }
29 }
30  
31 34 return join " ", @help;
32 }
33  
34 sub help {
35 19 ▶ my $self = shift;
Subroutine help: called CC=6 SCAR=17.9
Pod documented
36 19 printf "usage: %s %s\n", $self->parent->name, $self->help_short;
37 19 printf "\n";
38  
39 19 ▶ if ($self->description ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->description ne "") 18 1 19
40 18 printf "%s\n", $self->description;
41 18 printf "\n";
42 }
43  
44 19 printf "%s\n", $self->flags->help;
45  
46 19 ▶ if ($self->args->count > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->args->count > 0) 12 7 19
47 12 printf "%s\n", $self->args->help;
48 }
49  
50 19 ▶ if ($self->commands->count > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->commands->count > 1) 1 18 19
51 1 printf "Subcommands:\n";
52 1 foreach my $sub ($self->commands->get_all) {
53 2 ▶ next if $sub->name eq "help";
Branch: 1 branch
BranchTrueFalseTotal
if $sub->name eq "help" 1 1 2
54 1 printf " %s %s\n", $sub->parent->name, $sub->name;
55 1 printf " %s\n", $sub->description;
56 1 printf "\n";
57 }
58 }
59 }
60  
61 31 1;
62 __END__
« blib/lib/Getopt/Kingpin/Flag.pm ↑ Summary blib/lib/Getopt/Kingpin/Args.pm »