| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
884
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
24
|
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
31
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package App::Cmd::Subdispatch::DashedStyle 0.334; |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use App::Cmd::Subdispatch; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
12
|
|
|
7
|
1
|
|
|
1
|
|
421
|
BEGIN { our @ISA = 'App::Cmd::Subdispatch' }; |
|
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
|
|
|
|
|
|
|
sub get_command { |
|
23
|
0
|
|
|
0
|
1
|
|
my ($self, @args) = @_; |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my (undef, $opt, @sub_args) |
|
26
|
|
|
|
|
|
|
= $self->App::Cmd::Command::prepare($self->app, @args); |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
if (my $cmd = delete $opt->{subcommand}) { |
|
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 that calculates the getopt specification from the |
|
39
|
|
|
|
|
|
|
#pod subcommands. |
|
40
|
|
|
|
|
|
|
#pod |
|
41
|
|
|
|
|
|
|
#pod =cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub opt_spec { |
|
44
|
0
|
|
|
0
|
1
|
|
my ($self, $app) = @_; |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $subcommands = $self->_command; |
|
47
|
|
|
|
|
|
|
my %plugins = map { |
|
48
|
0
|
|
|
|
|
|
$_ => [ $_->command_names ], |
|
|
0
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} values %$subcommands; |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
foreach my $opt_spec (values %plugins) { |
|
52
|
0
|
|
|
|
|
|
$opt_spec = join("|", grep { /^\w/ } @$opt_spec); |
|
|
0
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my @subcommands = map { [ $plugins{$_} => $_->abstract ] } keys %plugins; |
|
|
0
|
|
|
|
|
|
|
|
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; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |