App-td
view release on metacpan or search on metacpan
lib/App/td.pm view on Meta::CPAN
tags => ['category:transpose-action'],
},
},
};
sub td {
my %args = @_;
my $action = $args{action};
my $argv = $args{argv};
my ($input, $input_form, $input_obj, $input_form_err);
GET_INPUT:
{
last unless $actions{$action}{req_input} // 1;
eval {
local $/;
$input = _decode_json(~~<STDIN>);
};
return [400, "Input is not valid JSON: $@"] if $@;
# give envelope if not enveloped
unless (ref($input) eq 'ARRAY' &&
lib/App/td.pm view on Meta::CPAN
$input->[0] =~ /\A[2-5]\d\d\z/ &&
!ref($input->[1])
) {
$input = [200, "Envelope added by td", $input];
}
# detect table form
($input_form, $input_obj, $input_form_err) = _get_td_obj($input);
return [400, "Input is not table data: $input_form_err"]
unless $input_form;
} # GET_INPUT
my $output;
PROCESS:
{
if ($action eq 'actions') {
if ($args{detail}) {
$output = [200, "OK", [map {+{name=>$_, summary=>$actions{$_}{summary}}} sort keys %actions]];
} else {
$output = [200, "OK", [sort keys %actions]];
}
lib/App/td.pm view on Meta::CPAN
}
}
$output = [200, "OK", \@output_rows, {'table.fields'=>\@output_cols}];
last;
}
return [400, "Unknown action '$action'"];
} # PROCESS
POSTPROCESS_OUTPUT:
{
require Pipe::Find;
my $pipeinfo = Pipe::Find::get_stdout_pipe_process();
last unless $pipeinfo;
last unless
$pipeinfo->{exe} =~ m![/\\]td\z! ||
$pipeinfo->{cmdline} =~ m!\A([^\0]*[/\\])?perl\0([^\0]*[/\\])?td\0!;
$output->[3]{'cmdline.default_format'} = 'json';
}
$output;
( run in 0.272 second using v1.01-cache-2.11-cpan-4e96b696675 )