JobLog/Command/parse.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 39 CC 3 SCAR 12.8
CC
3
Cov
0%
execute
6.0
validate
6.0
usage_desc
2.0
CRAP 3.6
1 package App::JobLog::Command::parse;
2 $App::JobLog::Command::parse::VERSION = '1.042';
3 # ABSTRACT: parse a time expression
4  
5 use App::JobLog -command;
6 use autouse 'App::JobLog::TimeGrammar' => qw(parse);
7  
8 use Modern::Perl;
9  
10 sub execute {
11 my ( $self, $opt, $args ) = @_;
12 my $expression = join ' ', @$args;
13 eval {
14 my ( $s, $e, $is_interval ) = parse $expression;
15 say <<END;
16
17 received: $expression
18 start time: $s
19 end time: $e
20 received interval: @{[$is_interval ? 'true' : 'false']}
21 END
22 };
23 $self->usage_error($@) if $@;
24 }
25  
26 sub validate {
27 my ( $self, $opt, $args ) = @_;
28 $self->usage_error('no time expression provided') unless @$args;
29 }
30  
31 sub usage_desc { '%c ' . __PACKAGE__->name }
32  
33 sub abstract { 'parse a time expression' }
34  
35 sub full_description {
36 <<END
37 If you are getting strange results with @{[App::JobLog::Command::summary->name]}, the problem
38 might be the time expression you're using. This command lets you see how your expression is
39 getting parsed.
40  
41 It repeats to you the phrase it has parsed, prints out the start and end time of the corresponding
42 interval, and finally, whether it understands itself to have received an expression of the form
43 <date> or <date> <separator> <date>, the latter form being called an "interval" for diagnostic
44 purposes.
45 END
46 }
47  
48 1;
49  
50 __END__