App-JobLog
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/JobLog/Command/when.pm view on Meta::CPAN
package App::JobLog::Command::when;
$App::JobLog::Command::when::VERSION = '1.042';
# ABSTRACT: when you'll be done for the day
use App::JobLog -command;
use Modern::Perl;
use Class::Autouse qw(
App::JobLog::Log
App::JobLog::Log::Day
);
use autouse 'App::JobLog::TimeGrammar' => qw(parse daytime);
use autouse 'Carp' => qw(carp);
use autouse 'Getopt::Long::Descriptive' => qw(prog_name);
use autouse 'App::JobLog::Config' => qw(
columns
is_hidden
merge
);
use autouse 'App::JobLog::Log::Format' => qw(
display
single_interval
summary
);
use autouse 'App::JobLog::Time' => qw(today now);
use constant FULL_FORMAT => '%l:%M:%S %p on %A, %B %d, %Y';
use constant SAME_YEAR_FORMAT => '%l:%M:%S %p on %A, %B %d';
use constant SAME_WEEK_FORMAT => '%l:%M:%S %p on %A';
use constant SAME_DAY_FORMAT => '%l:%M:%S %p';
sub execute {
my ( $self, $opt, $args ) = @_;
my $tags = $opt->tag || [];
my $excluded_tags = $opt->exclude_tag || [];
my $match = $opt->match || [];
my $no_match = $opt->no_match || [];
# validate regexes, if any, while generating test
my $test =
App::JobLog::Command::summary::_make_test( $tags, $excluded_tags, $match,
$no_match, undef );
# parse time expression
my $days;
my $start = ( join ' ', @$args ) || 'today';
eval { ( $days, undef ) = summary "$start through today", $test, {} };
$self->usage_error($@) if $@;
# check for long task
my ($last_e) = App::JobLog::Log->new->last_event;
if ( $last_e && $last_e->is_open ) {
my ( $then, $today ) = ( $last_e->start, today );
if (
!(
$then->year == $today->year
&& $then->month == $today->month
&& $then->day == $today->day
)
)
{
print <<END;
WARNING! The last event in the log has been open since before 12:00 am today!
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.603 second using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )