line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
2
|
|
|
|
|
|
|
package Test::Cool; |
3
|
2
|
|
|
2
|
|
3029
|
use Getopt::App -complete; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
20
|
|
4
|
2
|
|
|
2
|
|
12
|
use File::Spec::Functions qw(catdir catfile rel2abs updir); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
140
|
|
5
|
2
|
|
|
2
|
|
12
|
use File::Basename qw(dirname); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
678
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# getopt_subcommands() is called by Getopt::App |
8
|
|
|
|
|
|
|
sub getopt_subcommands { |
9
|
18
|
|
|
18
|
|
33
|
my $app = shift; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Can also use File::Share or $INC{'My/Module.pm'} to locate commands |
12
|
18
|
|
|
|
|
790
|
my $dir = catdir dirname(__FILE__), updir, qw(lib Test Cool commands); |
13
|
|
|
|
|
|
|
|
14
|
18
|
50
|
|
|
|
759
|
opendir(my ($DH), $dir) or die $!; |
15
|
90
|
|
|
|
|
1190
|
return [map { [s!\.pl$!!r, rel2abs(catfile $dir, $_), "Try $_"] } |
16
|
18
|
|
|
|
|
426
|
sort grep {/\.pl$/} readdir $DH]; |
|
126
|
|
|
|
|
424
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
run( |
20
|
|
|
|
|
|
|
'h # Print help', |
21
|
|
|
|
|
|
|
'completion-script # Print autocomplete script', |
22
|
|
|
|
|
|
|
sub { |
23
|
|
|
|
|
|
|
my ($app, @args) = @_; |
24
|
|
|
|
|
|
|
return print generate_completion_script() if $app->{'completion-script'}; |
25
|
|
|
|
|
|
|
return print extract_usage() if $app->{h}; |
26
|
|
|
|
|
|
|
say __FILE__; |
27
|
|
|
|
|
|
|
return 10; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
); |