| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::JobLog::Command::parse; |
|
2
|
|
|
|
|
|
|
$App::JobLog::Command::parse::VERSION = '1.039'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: parse a time expression |
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
1702
|
use App::JobLog -command; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
15
|
|
|
6
|
2
|
|
|
2
|
|
758
|
use autouse 'App::JobLog::TimeGrammar' => qw(parse); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
102
|
use Modern::Perl; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub execute { |
|
11
|
0
|
|
|
0
|
1
|
|
my ( $self, $opt, $args ) = @_; |
|
12
|
0
|
|
|
|
|
|
my $expression = join ' ', @$args; |
|
13
|
0
|
|
|
|
|
|
eval { |
|
14
|
0
|
|
|
|
|
|
my ( $s, $e, $is_interval ) = parse $expression; |
|
15
|
0
|
|
|
|
|
|
say <
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
received: $expression |
|
18
|
|
|
|
|
|
|
start time: $s |
|
19
|
|
|
|
|
|
|
end time: $e |
|
20
|
0
|
0
|
|
|
|
|
received interval: @{[$is_interval ? 'true' : 'false']} |
|
21
|
|
|
|
|
|
|
END |
|
22
|
|
|
|
|
|
|
}; |
|
23
|
0
|
0
|
|
|
|
|
$self->usage_error($@) if $@; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub validate { |
|
27
|
0
|
|
|
0
|
0
|
|
my ( $self, $opt, $args ) = @_; |
|
28
|
0
|
0
|
|
|
|
|
$self->usage_error('no time expression provided') unless @$args; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
1
|
|
sub usage_desc { '%c ' . __PACKAGE__->name } |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
1
|
|
sub abstract { 'parse a time expression' } |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub full_description { |
|
36
|
|
|
|
|
|
|
<
|
|
37
|
0
|
|
|
|
|
|
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
|
|
|
|
|
|
|
or , the latter form being called an "interval" for diagnostic |
|
44
|
|
|
|
|
|
|
purposes. |
|
45
|
|
|
|
|
|
|
END |
|
46
|
0
|
|
|
0
|
0
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |