App-JobLog
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/JobLog/Command/resume.pm view on Meta::CPAN
package App::JobLog::Command::resume;
$App::JobLog::Command::resume::VERSION = '1.042';
# ABSTRACT: resume last closed task
use App::JobLog -command;
use Modern::Perl;
use Class::Autouse 'App::JobLog::Log';
use autouse 'App::JobLog::Time' => qw(now);
sub execute {
my ( $self, $opt, $args ) = @_;
# construct event test
my %must = map { $_ => 1 } @{ $opt->tag || [] };
my %mustnt = map { $_ => 1 } @{ $opt->without || [] };
my $test = sub {
my $event = shift;
return if $event->is_note;
my @tags = @{ $event->tags };
my %tags = map { $_ => 1 } @tags;
my $good = 1;
if (%must) {
if ( $opt->any ) {
$good = 0;
for my $tag (@tags) {
if ( $must{$tag} ) {
$good = 1;
last;
}
}
}
else {
for my $tag ( keys %must ) {
unless ( $tags{$tag} ) {
$good = 0;
last;
}
}
}
}
if ( $good && %mustnt ) {
if ( $opt->some ) {
$good = 0;
for my $tag ( keys %mustnt ) {
unless ( $tags{$tag} ) {
$good = 1;
last;
}
}
}
else {
for my $tag (@tags) {
if ( $mustnt{$tag} ) {
$good = 0;
last;
}
}
}
}
return $good;
};
# find event
my $log = App::JobLog::Log->new;
my ( $i, $count, $e ) = ( $log->reverse_iterator, 0 );
while ( $e = $i->() ) {
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.697 second using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )