er
=head1 SYNOPSIS
my $crontab = Cron::Sequencer->new("/path/to/crontab");
print encode_json([$crontab->sequence($start, $end)]);
=head1 DESCRIPTION
This class can take one or more crontab
arse_argv);
my %known_json = map { $_, 1 } qw(seq split pretty canonical);
sub parse_argv {
my ($pod2usage, @argv) = @_;
my @groups;
my $current = [];
my $json;
# Split the com
) {
push @groups, $current;
$current = [];
} elsif ($item =~ /\A--json(?:=(.*)|)\z/s && !@groups) {
# GetOpt::Long doesn't appear to have a way to specify t
he '=' form.
# We'd like to support `--json` and `--json=pretty` but have
# `--json pretty` mean the same as `./pretty --json`
if (length $1) {
for
= %opts{qw(count group hide-env json)};
return bless \%state;
}
sub render {
my ($self, @groups) = @_;
return $self->{json}
? $self->render_json(@groups) : $self->render_text(@
output;
return join "\n", @output;
}
sub render_json {
my ($self, @groups) = @_;
require JSON::MaybeXS;
my %opts = $self->{json}->%*;
# CLI parser forbids 'seq' and 'split' sim
eq};
my $start = $seq ? "\x1E" : "";
my $split = delete $opts{split} || $seq;
my $json = JSON::MaybeXS->new(%opts);
my $munged;
if ($self->{'hide-env'}) {
# We shouldn't