| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::JobLog::Command::vacation; |
|
2
|
|
|
|
|
|
|
$App::JobLog::Command::vacation::VERSION = '1.041'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: controller for vacation dates |
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
1687
|
use Modern::Perl; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
12
|
|
|
6
|
2
|
|
|
2
|
|
279
|
use App::JobLog -command; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
14
|
|
|
7
|
2
|
|
|
2
|
|
761
|
use autouse 'App::JobLog::TimeGrammar' => qw(parse); |
|
|
2
|
|
|
|
|
74
|
|
|
|
2
|
|
|
|
|
12
|
|
|
8
|
2
|
|
|
|
|
7
|
use autouse 'App::JobLog::Vacation::Period' => qw( |
|
9
|
|
|
|
|
|
|
FLEX |
|
10
|
|
|
|
|
|
|
FIXED |
|
11
|
|
|
|
|
|
|
ANNUAL |
|
12
|
|
|
|
|
|
|
MONTHLY |
|
13
|
2
|
|
|
2
|
|
124
|
); |
|
|
2
|
|
|
|
|
5
|
|
|
14
|
2
|
|
|
2
|
|
203
|
use Class::Autouse qw(App::JobLog::Vacation); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
12
|
|
|
15
|
2
|
|
|
2
|
|
291
|
no if $] >= 5.018, warnings => "experimental::smartmatch"; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
12
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub execute { |
|
18
|
0
|
|
|
0
|
1
|
|
my ( $self, $opt, $args ) = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $vacation = App::JobLog::Vacation->new; |
|
21
|
0
|
0
|
|
|
|
|
if ( $opt->modification ) { |
|
22
|
0
|
|
|
|
|
|
eval { |
|
23
|
0
|
|
|
|
|
|
for ( $opt->modification ) |
|
24
|
|
|
|
|
|
|
{ |
|
25
|
0
|
|
|
|
|
|
when ('add') { |
|
26
|
0
|
|
|
|
|
|
my ( $s, $e ) = parse( $opt->add ); |
|
27
|
0
|
|
|
|
|
|
my $repeats; |
|
28
|
0
|
|
0
|
|
|
|
for ( $opt->{repeat} || '' ) { |
|
29
|
0
|
|
|
|
|
|
when ('annual') { $repeats = ANNUAL } |
|
|
0
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
when ('monthly') { $repeats = MONTHLY } |
|
|
0
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
default { $repeats = 0 }; |
|
|
0
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
|
33
|
0
|
|
|
|
|
|
my $flexibility; |
|
34
|
0
|
|
0
|
|
|
|
for ( $opt->{flexibility} || '' ) { |
|
35
|
0
|
|
|
|
|
|
when ('fixed') { $flexibility = FIXED } |
|
|
0
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
when ('flex') { $flexibility = FLEX } |
|
|
0
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
default { $flexibility = 0 }; |
|
|
0
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
$vacation->add( |
|
40
|
|
|
|
|
|
|
description => join( ' ', @$args ), |
|
41
|
|
|
|
|
|
|
time => $s, |
|
42
|
|
|
|
|
|
|
end => $e, |
|
43
|
|
|
|
|
|
|
repeats => $repeats, |
|
44
|
|
|
|
|
|
|
type => $flexibility, |
|
45
|
0
|
|
0
|
|
|
|
tags => $opt->{tag} || [], |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
0
|
|
|
|
|
|
when ('remove') { |
|
49
|
0
|
|
|
|
|
|
$vacation->remove( $opt->remove ); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
}; |
|
53
|
0
|
0
|
|
|
|
|
$self->usage_error($@) if $@; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
0
|
|
|
|
|
|
_show($vacation); |
|
56
|
0
|
|
|
|
|
|
$vacation->close; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _show { |
|
60
|
0
|
|
|
0
|
|
|
my ($vacation) = @_; |
|
61
|
0
|
|
|
|
|
|
my $lines = $vacation->show; |
|
62
|
0
|
0
|
|
|
|
|
if (@$lines) { |
|
63
|
0
|
|
|
|
|
|
print $_ for @$lines; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
else { |
|
66
|
0
|
|
|
|
|
|
say 'no vacation times recorded'; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
0
|
1
|
|
sub usage_desc { '%c ' . __PACKAGE__->name . ' %o []' } |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
0
|
1
|
|
sub abstract { 'list or define days off' } |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub options { |
|
75
|
|
|
|
|
|
|
return ( |
|
76
|
0
|
|
|
0
|
0
|
|
[ 'list|l', 'show all vacation times recorded', ], |
|
77
|
|
|
|
|
|
|
[ |
|
78
|
|
|
|
|
|
|
'flexibility' => hidden => { |
|
79
|
|
|
|
|
|
|
one_of => [ |
|
80
|
|
|
|
|
|
|
[ |
|
81
|
|
|
|
|
|
|
'flex|f', |
|
82
|
|
|
|
|
|
|
'add sufficient vacation time to complete workday; this is recorded with the "flex" tag' |
|
83
|
|
|
|
|
|
|
], |
|
84
|
|
|
|
|
|
|
[ |
|
85
|
|
|
|
|
|
|
'fixed|x', |
|
86
|
|
|
|
|
|
|
'a particular period of time during the day that should be marked as vacation; ' |
|
87
|
|
|
|
|
|
|
. 'this is in effect a special variety of work time, since it has a definite start and duration' |
|
88
|
|
|
|
|
|
|
], |
|
89
|
|
|
|
|
|
|
] |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
], |
|
92
|
|
|
|
|
|
|
[ 'tag|t=s@', 'tag vacation time; e.g., -a yesterday -t float' ], |
|
93
|
|
|
|
|
|
|
[ |
|
94
|
|
|
|
|
|
|
'repeat' => 'hidden' => { |
|
95
|
|
|
|
|
|
|
one_of => [ |
|
96
|
|
|
|
|
|
|
[ 'annual', 'vacation period repeats annually' ], |
|
97
|
|
|
|
|
|
|
[ 'monthly', 'vacation period repeats monthly' ], |
|
98
|
|
|
|
|
|
|
] |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
], |
|
101
|
|
|
|
|
|
|
[ |
|
102
|
|
|
|
|
|
|
'modification' => 'hidden' => { |
|
103
|
|
|
|
|
|
|
one_of => [ |
|
104
|
|
|
|
|
|
|
[ 'add|a=s', 'add date or range; e.g., -a "May 17, 1951"' ], |
|
105
|
|
|
|
|
|
|
[ |
|
106
|
|
|
|
|
|
|
'remove|r=i', |
|
107
|
|
|
|
|
|
|
'remove period with given index from list (see --list); e.g., -r 1' |
|
108
|
|
|
|
|
|
|
], |
|
109
|
|
|
|
|
|
|
] |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
] |
|
112
|
|
|
|
|
|
|
); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub validate { |
|
116
|
0
|
|
|
0
|
0
|
|
my ( $self, $opt, $args ) = @_; |
|
117
|
|
|
|
|
|
|
|
|
118
|
0
|
0
|
|
|
|
|
if ( $opt->modification ) { |
|
119
|
0
|
0
|
|
|
|
|
$self->usage_error('either list or modify') if $opt->list; |
|
120
|
0
|
0
|
0
|
|
|
|
$self->usage_error('no description provided') |
|
121
|
|
|
|
|
|
|
if $opt->modification eq 'add' |
|
122
|
|
|
|
|
|
|
&& !@$args; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
else { |
|
125
|
0
|
0
|
|
|
|
|
$self->usage_error('--tag requires that you add a date') |
|
126
|
|
|
|
|
|
|
if $opt->tag; |
|
127
|
0
|
0
|
|
|
|
|
$self->usage_error('--annual and --monthly require --add') |
|
128
|
|
|
|
|
|
|
if $opt->repeat; |
|
129
|
0
|
0
|
|
|
|
|
$self->usage_error('either list or modify') unless $opt->list; |
|
130
|
0
|
0
|
|
|
|
|
$self->usage_error('both --flex and --fixed require --add') |
|
131
|
|
|
|
|
|
|
if $opt->flexibility; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
__END__ |