example/bin/cool

filter: Statementstmt 100% 24 / 24 Branchbran 66.6% 4 / 6 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 94.8% 37 / 39 CC 5 SCAR 7.0
CC
5
Cov
94%
__ANON__
3.0
getopt_subcommands
2.0
command_foo
2.0
CRAP 2.0
« blib/lib/Getopt/App/Complete.pm ↑ Summary example/lib/Test/Cool/commands/unknown.pl »
1 #!/usr/bin/env perl
2 package Test::Cool;
3 2 ▶use Getopt::App -complete;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use File::Spec::Functions qw(catdir catfile rel2abs updir);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use File::Basename qw(dirname);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 sub command_foo {
8 2 ▶ my ($app, @args) = @_;
Subroutine command_foo: called CC=2 SCAR=6.9
9 2 ▶ printf qq(args=%s foo=%s\n), join(',', @args), $app->{foo} // '';
Condition100%2/2
$app->{"foo"} // ""
l!l
11
MC/DC100%1/1
$app->{"foo"} // ""
$app->{"foo"}
Truth table100%2/2
A
A= $app->{"foo"}
Aresult
11
00
10 }
11  
12 # getopt_subcommands() is called by Getopt::App
13 sub getopt_subcommands {
14 20 ▶ my $app = shift;
Subroutine getopt_subcommands: called CC=2 SCAR=7.0
15 20 my $method = ['foo', 'command_foo', 'internal method'];
16  
17 # Can also use File::Share or $INC{'My/Module.pm'} to locate commands
18 20 my $dir = catdir dirname(__FILE__), updir, qw(lib Test Cool commands);
19  
20 20 ▶ opendir(my ($DH), $dir) or die $!;
Branch: 1 branch
BranchTrueFalseTotal
opendir my $DH, $dir or die $! 0 20 20
21 20 return [$method, map { [s!\.pl$!!r, rel2abs(catfile $dir, $_), "Try $_"] } sort grep {/\.pl$/} readdir $DH];
22 }
23  
24 run(
25 'foo=s # Argument for foo',
26 'h # Print help',
27 'completion-script # Print autocomplete script',
28 sub {
29 2 ▶ my ($app, @args) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.0
30 2 ▶ return print generate_completion_script() if $app->{'completion-script'};
Branch: 1 branch
BranchTrueFalseTotal
if $app->{"completion-script"} 0 2 2
31 2 ▶ return print extract_usage() if $app->{h};
Branch: 1 branch
BranchTrueFalseTotal
if $app->{"h"} 1 1 2
32 1 say __FILE__;
33 1 return 10;
34 }
35 2 );
« blib/lib/Getopt/App/Complete.pm ↑ Summary example/lib/Test/Cool/commands/unknown.pl »