App-JobLog
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/JobLog/Command/vacation.pm view on Meta::CPAN
package App::JobLog::Command::vacation;
$App::JobLog::Command::vacation::VERSION = '1.042';
# ABSTRACT: controller for vacation dates
use Modern::Perl;
use App::JobLog -command;
use autouse 'App::JobLog::TimeGrammar' => qw(parse);
use autouse 'App::JobLog::Vacation::Period' => qw(
FLEX
FIXED
ANNUAL
MONTHLY
);
use Class::Autouse qw(App::JobLog::Vacation);
no if $] >= 5.018, warnings => "experimental::smartmatch";
sub execute {
my ( $self, $opt, $args ) = @_;
my $vacation = App::JobLog::Vacation->new;
if ( $opt->modification ) {
eval {
for ( $opt->modification )
{
when ('add') {
my ( $s, $e ) = parse( $opt->add );
my $repeats;
for ( $opt->{repeat} || '' ) {
when ('annual') { $repeats = ANNUAL }
when ('monthly') { $repeats = MONTHLY }
default { $repeats = 0 };
}
my $flexibility;
for ( $opt->{flexibility} || '' ) {
when ('fixed') { $flexibility = FIXED }
when ('flex') { $flexibility = FLEX }
default { $flexibility = 0 };
}
$vacation->add(
description => join( ' ', @$args ),
time => $s,
end => $e,
repeats => $repeats,
type => $flexibility,
tags => $opt->{tag} || [],
);
}
when ('remove') {
$vacation->remove( $opt->remove );
}
}
};
$self->usage_error($@) if $@;
}
_show($vacation);
$vacation->close;
}
sub _show {
my ($vacation) = @_;
my $lines = $vacation->show;
if (@$lines) {
print $_ for @$lines;
}
else {
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.681 second using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )