App-JobLog

 view release on metacpan or  search on metacpan

lib/App/JobLog/Command/last.pm  view on Meta::CPAN

package App::JobLog::Command::last;
$App::JobLog::Command::last::VERSION = '1.042';
# ABSTRACT: show details of last recorded event

use Modern::Perl;
use App::JobLog -command;
use Class::Autouse qw(
  App::JobLog::Log
  App::JobLog::Command::summary
);

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

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.590 second using v1.00-cache-2.02-grep-82fe00e-cpan-cec75d87357c )