Cmd/Subdispatch/DashedStyle.pm

filter: Statementstmt 40.7% 11 / 27 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 100% 2 / 2 totaltotal 45.9% 17 / 37 CC 3 SCAR 12.5
CC
3
Cov
38%
get_command
6.0
opt_spec
6.0
BEGIN
1.0
CRAP 3.5
« Cmd/Setup.pm ↑ Summary Cmd.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package App::Cmd::Subdispatch::DashedStyle 0.340;
5  
6 1 ▶use App::Cmd::Subdispatch;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶BEGIN { our @ISA = 'App::Cmd::Subdispatch' };
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: "app cmd --subcmd" style subdispatching
10  
11 #pod =method get_command
12 #pod
13 #pod my ($subcommand, $opt, $args) = $subdispatch->get_command(@args)
14 #pod
15 #pod A version of get_command that chooses commands as options in the following
16 #pod style:
17 #pod
18 #pod mytool mycommand --mysubcommand
19 #pod
20 #pod =cut
21  
22 0 ▶sub get_command {
Subroutine get_command: not called CC=2 SCAR=17.9
Pod documented
23 0 my ($self, @args) = @_;
24  
25 0 my (undef, $opt, @sub_args)
26 = $self->App::Cmd::Command::prepare($self->app, @args);
27  
28 0 ▶ if (my $cmd = delete $opt->{subcommand}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cmd = delete $opt->{'subcommand'}) { } 0 0 0
29 0 delete $opt->{$cmd}; # useless boolean
30 0 return ($cmd, $opt, @sub_args);
31 } else {
32 0 return (undef, $opt, @sub_args);
33 }
34 }
35  
36 #pod =method opt_spec
37 #pod
38 #pod A version of C<opt_spec> that calculates the getopt specification from the
39 #pod subcommands.
40 #pod
41 #pod =cut
42  
43 0 ▶sub opt_spec {
Subroutine opt_spec: not called CC=2 SCAR=17.9
Pod documented
44 0 my ($self, $app) = @_;
45  
46 0 my $subcommands = $self->_command;
47 my %plugins = map {
48 0 $_ => [ $_->command_names ],
49 } values %$subcommands;
50  
51 0 foreach my $opt_spec (values %plugins) {
52 0 $opt_spec = join("|", grep { /^\w/ } @$opt_spec);
53 }
54  
55 0 my @subcommands = map { [ $plugins{$_} => $_->abstract ] } keys %plugins;
56  
57 return (
58 0 [ subcommand => hidden => { one_of => \@subcommands } ],
59 $self->global_opt_spec($app),
60 { getopt_conf => [ 'pass_through' ] },
61 );
62 }
63  
64 1 1;
65  
66 __END__
« Cmd/Setup.pm ↑ Summary Cmd.pm »