App-JobLog
view release on metacpan or search on metacpan
lib/App/JobLog/Command/vacation.pm view on Meta::CPAN
_show($vacation);
$vacation->close;
}
sub _show {
my ($vacation) = @_;
my $lines = $vacation->show;
if (@$lines) {
print $_ for @$lines;
}
else {
say 'no vacation times recorded';
}
}
sub usage_desc { '%c ' . __PACKAGE__->name . ' %o [<description>]' }
sub abstract { 'list or define days off' }
sub options {
return (
[ 'list|l', 'show all vacation times recorded', ],
[
'flexibility' => hidden => {
one_of => [
[
'flex|f',
'add sufficient vacation time to complete workday; this is recorded with the "flex" tag'
],
[
'fixed|x',
'a particular period of time during the day that should be marked as vacation; '
. 'this is in effect a special variety of work time, since it has a definite start and duration'
],
]
}
],
[ 'tag|t=s@', 'tag vacation time; e.g., -a yesterday -t float' ],
[
'repeat' => 'hidden' => {
one_of => [
[ 'annual', 'vacation period repeats annually' ],
[ 'monthly', 'vacation period repeats monthly' ],
]
}
],
[
'modification' => 'hidden' => {
one_of => [
[ 'add|a=s', 'add date or range; e.g., -a "May 17, 1951"' ],
[
'remove|r=i',
'remove period with given index from list (see --list); e.g., -r 1'
],
]
}
]
);
}
sub validate {
my ( $self, $opt, $args ) = @_;
if ( $opt->modification ) {
$self->usage_error('either list or modify') if $opt->list;
$self->usage_error('no description provided')
if $opt->modification eq 'add'
&& !@$args;
}
else {
$self->usage_error('--tag requires that you add a date')
if $opt->tag;
$self->usage_error('--annual and --monthly require --add')
if $opt->repeat;
$self->usage_error('either list or modify') unless $opt->list;
$self->usage_error('both --flex and --fixed require --add')
if $opt->flexibility;
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
App::JobLog::Command::vacation - controller for vacation dates
=head1 VERSION
version 1.042
=head1 SYNOPSIS
houghton@NorthernSpy:~$ job vacation --help
job <command>
job vacation [-aflrtx] [long options...] [<description>]
-l --list show all vacation times recorded
-f --flex add sufficient vacation time to complete workday;
this is recorded with the "flex" tag
-x --fixed a particular period of time during the day that
should be marked as vacation; this is in effect a
special variety of work time, since it has a definite
start and duration
-t --tag tag vacation time; e.g., -a yesterday -t float
--annual vacation period repeats annually
--monthly vacation period repeats monthly
-a --add add date or range; e.g., -a "May 17, 1951"
-r --remove remove period with given index from list (see
--list); e.g., -d 1
--help this usage screen
houghton@NorthernSpy:~$ job v --list
no vacation times recorded
houghton@NorthernSpy:~$ job v --add today job day
1) 2011-03-07 job day
houghton@NorthernSpy:~$ job v -a 15 --monthly Ides
( run in 0.637 second using v1.01-cache-2.11-cpan-39bf76dae61 )