File Coverage

blib/lib/App/Yath/Script/V0.pm
Criterion Covered Total %
statement 23 25 92.0
branch 1 2 50.0
path n/a
condition 2 4 50.0
subroutine 5 5 100.0
pod 0 2 0.0
total 31 38 81.5


line stmt bran path cond sub pod time code
1               package App::Yath::Script::V0;
2 14       14   180131 use strict;
  14           20  
  14           554  
3 14       14   106 use warnings;
  14           20  
  14           838  
4                
5 14       14   6764 use Getopt::Yath;
  14           1270637  
  14           85  
6                
7               our $VERSION = '2.000011';
8                
9               my @BEGIN_ARGS;
10                
11               option_group {group => 'v0', category => 'V0 Options'} => sub {
12               option begin => (
13               type => 'List',
14               description => 'Arguments to process during the BEGIN phase',
15               );
16                
17               option goto_file => (
18               type => 'Scalar',
19               description => 'Use goto::file to switch to a different file during BEGIN (for testing)',
20               );
21               };
22                
23               sub do_begin {
24 15       15 0 141414 my $class = shift;
25 15           75 my %params = @_;
26                
27 15           28 my $argv = $params{argv};
28                
29 15           48 my $state = parse_options($argv, skip_non_opts => 1);
30 15     50     8730 @BEGIN_ARGS = @{$state->{settings}->v0->begin // []};
  15           123  
31                
32               # Non-option args go back into @ARGV for do_runtime
33 15     50     680 @ARGV = @{$state->{skipped} // []};
  15           63  
34                
35 15           137 print "BEGIN: $_\n" for @BEGIN_ARGS;
36                
37 15           77 my $goto = $state->{settings}->v0->goto_file;
38 15 50         566 if ($goto) {
39 0           0 require goto::file;
40 0           0 goto::file->import($goto);
41               }
42               }
43                
44               sub do_runtime {
45 15       15 0 4259 my $class = shift;
46                
47 15           101 print "RUNTIME: $_\n" for @ARGV;
48                
49 15           1010 return 0;
50               }
51                
52               1;
53                
54               __END__