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/Flags.pm ↑ Summary blib/lib/Getopt/Kingpin/Args.pm »
1 package Getopt::Kingpin::Command;
2 28 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 28 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 28 ▶use Getopt::Kingpin -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 28 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 28 our $VERSION = "0.09";
9  
10 sub help_short {
11 32 ▶ my $self = shift;
Subroutine help_short: called CC=5 SCAR=16.1
Pod documented
12 32 my @help = ($self->name);
13  
14 32 ▶ if ($self->name eq "help") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->name eq 'help') { } 6 26 32
15 6 push @help, "[<command>...]";
16 } else {
17 26 ▶ if ($self->flags->count > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->flags->count > 1) 17 9 26
18 17 push @help, "[<flags>]";
19 }
20  
21 26 ▶ if ($self->commands->count > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->commands->count > 0) { } 1 25 26
22 1 push @help, "<command>";
23 1 push @help, "[<args> ...]";
24 } else {
25 25 foreach my $arg ($self->args->get_all) {
26 21 push @help, $arg->help_name(1);
27 }
28 }
29 }
30  
31 32 return join " ", @help;
32 }
33  
34 sub help {
35 17 ▶ my $self = shift;
Subroutine help: called CC=6 SCAR=17.9
Pod documented
36 17 printf "usage: %s %s\n", $self->parent->name, $self->help_short;
37 17 printf "\n";
38  
39 17 ▶ if ($self->description ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->description ne "") 16 1 17
40 16 printf "%s\n", $self->description;
41 16 printf "\n";
42 }
43  
44 17 printf "%s\n", $self->flags->help;
45  
46 17 ▶ if ($self->args->count > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->args->count > 0) 10 7 17
47 10 printf "%s\n", $self->args->help;
48 }
49  
50 17 ▶ if ($self->commands->count > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->commands->count > 1) 1 16 17
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 28 1;
62 __END__
« blib/lib/Getopt/Kingpin/Flags.pm ↑ Summary blib/lib/Getopt/Kingpin/Args.pm »