| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# The "experimental" below is not actually scary. The feature went on to be |
|
2
|
|
|
|
|
|
|
# de-experimental-ized with no changes and is now on by default in perl v5.24 |
|
3
|
|
|
|
|
|
|
# and later. -- rjbs, 2021-03-14 |
|
4
|
2
|
|
|
2
|
|
1940
|
use 5.020; |
|
|
2
|
|
|
|
|
7
|
|
|
5
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
57
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use experimental qw(postderef postderef_qq); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package App::Cmd::Subdispatch 0.336; |
|
9
|
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
413
|
use App::Cmd; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
10
|
|
|
11
|
2
|
|
|
2
|
|
1090
|
use App::Cmd::Command; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
92
|
|
|
12
|
2
|
|
|
2
|
|
1021
|
BEGIN { our @ISA = qw(App::Cmd::Command App::Cmd) } |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: an App::Cmd::Command that is also an App::Cmd |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#pod =method new |
|
17
|
|
|
|
|
|
|
#pod |
|
18
|
|
|
|
|
|
|
#pod A hackish new that allows us to have an Command instance before they normally |
|
19
|
|
|
|
|
|
|
#pod exist. |
|
20
|
|
|
|
|
|
|
#pod |
|
21
|
|
|
|
|
|
|
#pod =cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
|
24
|
2
|
|
|
2
|
1
|
4
|
my ($inv, $fields, @args) = @_; |
|
25
|
2
|
50
|
|
|
|
15
|
if (ref $inv) { |
|
26
|
0
|
|
|
|
|
0
|
@{ $inv }{ keys %$fields } = values %$fields; |
|
|
0
|
|
|
|
|
0
|
|
|
27
|
0
|
|
|
|
|
0
|
return $inv; |
|
28
|
|
|
|
|
|
|
} else { |
|
29
|
2
|
|
|
|
|
15
|
$inv->SUPER::new($fields, @args); |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#pod =method prepare |
|
34
|
|
|
|
|
|
|
#pod |
|
35
|
|
|
|
|
|
|
#pod my $subcmd = $subdispatch->prepare($app, @args); |
|
36
|
|
|
|
|
|
|
#pod |
|
37
|
|
|
|
|
|
|
#pod An overridden version of L that performs a new |
|
38
|
|
|
|
|
|
|
#pod dispatch cycle. |
|
39
|
|
|
|
|
|
|
#pod |
|
40
|
|
|
|
|
|
|
#pod =cut |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub prepare { |
|
43
|
2
|
|
|
2
|
1
|
4
|
my ($class, $app, @args) = @_; |
|
44
|
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
9
|
my $self = $class->new({ app => $app }); |
|
46
|
|
|
|
|
|
|
|
|
47
|
2
|
|
|
|
|
20
|
my ($subcommand, $opt, @sub_args) = $self->get_command(@args); |
|
48
|
|
|
|
|
|
|
|
|
49
|
2
|
|
|
|
|
10
|
$self->set_global_options($opt); |
|
50
|
|
|
|
|
|
|
|
|
51
|
2
|
100
|
|
|
|
6
|
if (defined $subcommand) { |
|
52
|
1
|
|
|
|
|
7
|
return $self->_prepare_command($subcommand, $opt, @sub_args); |
|
53
|
|
|
|
|
|
|
} else { |
|
54
|
1
|
50
|
|
|
|
4
|
if (@args) { |
|
55
|
0
|
|
|
|
|
0
|
return $self->_bad_command(undef, $opt, @sub_args); |
|
56
|
|
|
|
|
|
|
} else { |
|
57
|
1
|
|
|
|
|
7
|
return $self->_prepare_default_command($opt, @sub_args); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _plugin_prepare { |
|
63
|
0
|
|
|
0
|
|
|
my ($self, $plugin, @args) = @_; |
|
64
|
0
|
|
|
|
|
|
return $plugin->prepare($self->choose_parent_app($self->app, $plugin), @args); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#pod =method app |
|
68
|
|
|
|
|
|
|
#pod |
|
69
|
|
|
|
|
|
|
#pod $subdispatch->app; |
|
70
|
|
|
|
|
|
|
#pod |
|
71
|
|
|
|
|
|
|
#pod This method returns the application that this subdispatch is a command of. |
|
72
|
|
|
|
|
|
|
#pod |
|
73
|
|
|
|
|
|
|
#pod =cut |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
1
|
|
sub app { $_[0]{app} } |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#pod =method choose_parent_app |
|
78
|
|
|
|
|
|
|
#pod |
|
79
|
|
|
|
|
|
|
#pod $subcmd->prepare( |
|
80
|
|
|
|
|
|
|
#pod $subdispatch->choose_parent_app($app, $opt, $plugin), |
|
81
|
|
|
|
|
|
|
#pod @$args |
|
82
|
|
|
|
|
|
|
#pod ); |
|
83
|
|
|
|
|
|
|
#pod |
|
84
|
|
|
|
|
|
|
#pod A method that chooses whether the parent app or the subdispatch is going to be |
|
85
|
|
|
|
|
|
|
#pod C<< $cmd->app >>. |
|
86
|
|
|
|
|
|
|
#pod |
|
87
|
|
|
|
|
|
|
#pod =cut |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub choose_parent_app { |
|
90
|
0
|
|
|
0
|
1
|
|
my ( $self, $app, $plugin ) = @_; |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
0
|
0
|
|
|
|
if ( |
|
|
|
|
0
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$plugin->isa("App::Cmd::Command::commands") |
|
94
|
|
|
|
|
|
|
or $plugin->isa("App::Cmd::Command::help") |
|
95
|
|
|
|
|
|
|
or keys $self->global_options->%* |
|
96
|
|
|
|
|
|
|
) { |
|
97
|
0
|
|
|
|
|
|
return $self; |
|
98
|
|
|
|
|
|
|
} else { |
|
99
|
0
|
|
|
|
|
|
return $app; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |