App-after

 view release on metacpan or  search on metacpan

bin/after  view on Meta::CPAN

    },
    'no-or' => sub {
        $_pci_args{'or'} = $_[1];
    },
    'noall' => sub {
        $_pci_args{'all'} = $_[1];
    },
    'none' => sub {
        $_pci_args{'none'} = $_[1];
    },
    'nonone' => sub {
        $_pci_args{'none'} = $_[1];
    },
    'noor' => sub {
        $_pci_args{'or'} = $_[1];
    },
    'or' => sub {
        $_pci_args{'or'} = $_[1];
    },
    'time=s' => sub {
        $_pci_args{'time'} = $_[1];
    },
    'uptime=s' => sub {
        $_pci_args{'uptime'} = $_[1];
    },
    'version|v' => sub {
        no warnings 'once';
        require App::after;
        print "after version ", "0.04", ($App::after::DATE ? " ($App::after::DATE)" : ''), "\n";
        print "  Generated by Perinci::CmdLine::Inline version 0.38 (2016-05-21)\n";
        exit 0;
    },
};
my $res = Getopt::Long::EvenLess::GetOptions(%$go_spec);
_pci_err([500, "GetOptions failed"]) unless $res;
require Local::_pci_check_args; $res = _pci_check_args(\%_pci_args);
_pci_err($res) if $res->[0] != 200;
$_pci_r->{args} = \%_pci_args;
}

### call function

{
require App::after;
eval { $_pci_r->{res} = App::after::after(%_pci_args) };
if ($@) { $_pci_r->{res} = [500, "Function died: $@"] }
}

### format & display result

{
my $fres;
my $save_res; if (exists $_pci_r->{res}[3]{"cmdline.result"}) { $save_res = $_pci_r->{res}[2]; $_pci_r->{res}[2] = $_pci_r->{res}[3]{"cmdline.result"} }
my $is_success = $_pci_r->{res}[0] =~ /\A2/ || $_pci_r->{res}[0] == 304;
my $is_stream = $_pci_r->{res}[3]{stream} // undef // 0;
if ($is_success && (0 || $_pci_r->{res}[3]{"cmdline.skip_format"})) { $fres = $_pci_r->{res}[2] }
elsif ($is_success && $is_stream) {}
else { require Local::_pci_clean_json; require Perinci::Result::Format::Lite; $is_stream=0; _pci_clean_json($_pci_r->{res}); $fres = Perinci::Result::Format::Lite::format($_pci_r->{res}, ($_pci_r->{format} // $_pci_r->{res}[3]{"cmdline.default_format...

my $use_utf8 = $_pci_r->{res}[3]{"x.hint.result_binary"} ? 0 : 0;
if ($use_utf8) { binmode STDOUT, ":utf8" }
if ($is_stream) {
    my $code = $_pci_r->{res}[2]; if (ref($code) ne "CODE") { die "Result is a stream but no coderef provided" } if (0) { while(defined(my $l=$code->())) { print $l; print "\n" unless "" eq "buf"; } } else { while (defined(my $rec=$code->())) { print...
} else {
    print $fres;
}
if (defined $save_res) { $_pci_r->{res}[2] = $save_res }
}

### exit

{
my $status = $_pci_r->{res}[0];
my $exit_code = $_pci_r->{res}[3]{"cmdline.exit_code"} // ($status =~ /200|304/ ? 0 : ($status-300));
exit($exit_code);
}

=pod

=encoding UTF-8

=head1 NAME

after - Run command after delay and/or other conditions

=head1 VERSION

This document describes version 0.04 of main (from Perl distribution App-after), released on 2016-05-21.

=head1 SYNOPSIS

Usage:

 % after [options] <command>...

Examples:

Run command after 30-minute delay:

 % after --delay 30m cmd

Run command after 12 hour delay and time has passed 2016-04-18:

 % after --delay 12h --time 2016-04-18 cmd

Run command after 12 hour delay *or* time has passed 2016-04-18:

 % after --or --delay 12h --time 2016-04-18 cmd

Run command after system uptime is 2 days:

 % after --uptime 2d cmd

Run command after system load is above 2.5:

 % after --load-above 2.5 cmd

Run command after system load is between 1 and 5:

 % after --load-above 1 --load-below 5 cmd



( run in 1.018 second using v1.01-cache-2.11-cpan-524268b4103 )