line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CLI::Dispatch::Docopt; |
2
|
1
|
|
|
1
|
|
42001
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
98
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my $SubCmd = 'sub_command'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub import { |
10
|
1
|
|
|
1
|
|
8
|
my ($class, $name) = @_; |
11
|
|
|
|
|
|
|
|
12
|
1
|
50
|
|
|
|
6
|
$SubCmd = $name if defined $name; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
3
|
my $caller = caller; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; ## no critic |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
389
|
|
17
|
1
|
|
|
|
|
13
|
*{"${caller}::run"} = sub { |
18
|
0
|
|
|
0
|
|
|
CLI::Dispatch::Docopt->run(@_); |
19
|
1
|
|
|
|
|
4
|
}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub run { |
23
|
0
|
|
|
0
|
1
|
|
my ($class, $base, $opt, $method) = @_; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
0
|
|
|
|
$method ||= 'run'; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $module = $base; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
for my $key (keys %{$opt}) { |
|
0
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
next unless $key eq "<$SubCmd>"; |
31
|
0
|
|
|
|
|
|
$module = "${base}::". ucfirst($opt->{$key}); |
32
|
0
|
|
|
|
|
|
last; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $module_path = $module; |
36
|
0
|
|
|
|
|
|
$module_path =~ s!::!/!g; |
37
|
0
|
|
|
|
|
|
$module_path .= ".pm"; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
require $module_path; |
40
|
0
|
|
|
|
|
|
$module->$method($opt); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |