App-dux
view release on metacpan or search on metacpan
- Switch from Log::Any to Log::Any::IfLOG.
1.48 2014-12-27 Released-By: PERLANCAR
- Replace Module::Path with Module::Path::More.
1.47 2014-10-30 Released-By: PERLANCAR
- Turn off streaming if response is an error response, so user can
see the error.
1.46 2014-09-16 Released-By: PERLANCAR
- Fix broken stuff (adjust to new Perinci::CmdLine::*).
- Switch from Perinci::CmdLine to Perinci::CmdLine::Lite for faster
startup.
[BUG FIXES]
- 'dux -l' didn't recurse.
1.32 2013-04-14 Released-By: SHARYANTO
[ENHANCEMENTS]
- Support output streaming (for infinite outputs and immediate
displaying of result). Format needs to be 'text', function needs to
declare a true 'x.dux.is_stream_output' property attribute, where dux
will setup a tied array which prints result as items are being pushed
to it.
1.31 2013-04-13 Released-By: SHARYANTO
- No functional changes. Set Perinci::CmdLine dep version.
lib/Perinci/CmdLine/dux.pm view on Meta::CPAN
1;
require Tie::Diamond;
tie my(@diamond), 'Tie::Diamond', {chomp=>$chomp, utf8=>1} or die;
$r->{args}{in} = \@diamond;
# set `out` argument for the dux function
my $streamo = $r->{meta}{"x.app.dux.is_stream_output"} //
$r->{meta}{"x.dux.is_stream_output"}; # backward-compat, will be removed someday
my $fmt = $r->{format} // 'text';
if (!defined($streamo)) {
# turn on streaming if format is simple text
my $iactive;
if (-t STDOUT) {
$iactive = 1;
} elsif ($ENV{INTERACTIVE}) {
$iactive = 1;
} elsif (defined($ENV{INTERACTIVE}) && !$ENV{INTERACTIVE}) {
$iactive = 0;
}
$streamo = 1 if $fmt eq 'text-simple' || $fmt eq 'text' && !$iactive;
}
lib/Perinci/CmdLine/dux.pm view on Meta::CPAN
}
$r->{args}{-dux_cli} = 1;
$self->SUPER::action_call($r);
}
sub hook_format_result {
my ($self, $r) = @_;
# turn off streaming if response is an error response
if ($r->{res}[0] !~ /\A2/) {
$r->{is_stream_output} = 0;
}
return '' if $r->{is_stream_output};
if ($r->{res} && $r->{res}[0] == 200 && $r->{args}{-dux_cli}) {
# insert out to result, so it can be displayed
$r->{res}[2] = $r->{args}{out};
}
( run in 0.251 second using v1.01-cache-2.11-cpan-4d50c553e7e )