Perinci-CmdLine-Lite

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

	- Replace JSON with JSON::MaybeXS.


1.51    2016-02-26  Released-By: PERLANCAR

	- Implement cmdline_src=stdin_or_args (Rinci 1.1.79).


1.50    2016-02-04  Released-By: PERLANCAR

	- [Bugfix] When streaming input (argument) has schema=array, use
	  its 'of' clause subschema.

	- Adjust to Complete::Bash 0.27.

	- In completing --config-profile, force reading of config files
	  (previously if program has subcommands and no subcommand name is
	  specified in ARGV, parse_argv() will skip directly to --help.


1.49    2016-01-23  Released-By: PERLANCAR

Changes  view on Meta::CPAN


	- [Bugfix] Config sections should be read according to the order
	  they are seen in the files.


1.48    2016-01-22  Released-By: PERLANCAR

	- Bump prereq version Test::Perinci::CmdLine to 1.37.

	- Observe cmdline.chomp (allow turning-off autochomping of
	  streaming input record).


1.47    2016-01-22  Released-By: PERLANCAR

        - Chomp streaming input record, unless type is 'buf'. Adjust to
          Test::Perinci::CmdLine 1.36.


1.46    2016-01-21  Released-By: PERLANCAR

	- Update to Test::Perinci::CmdLine 1.33.

	- Allow filtering config section with program=...

	- Add use_utf8 to Lite, just like in Classic.

Changes  view on Meta::CPAN

        - Add JSON stream (input, output) support. Currently this is only
          minimally documented. Basically, if argument type is non-simple, then
          each input stream line will be assumed to be in JSON (an exception
          will be thrown if it does not parse as valid JSON) and will be decoded
          before fed to function. Likewise, if result type is non-simple, then
          every record will be encoded to JSON to produce JSON stream.


0.80    2015-01-17  Released-By: PERLANCAR

        - Support Rinci 1.1.71, where streaming input & output uses coderef
          only.

        - [Bugfix] Respect 'result/stream' metadata property which provides
          default for whether result is streaming or not (it is overriden by the
          'stream' result metadata property).

        - [doc] Reorganize manual: to avoid confusion, move all examples from
          FAQ to Examples. Add examples for result streaming. Update examples.


0.79    2015-01-15  Released-By: PERLANCAR

	- Fixes in help message (program summary from meta was not
	  displayed, show subcommands, passed wrong variable).


0.78    2015-01-14  Released-By: PERLANCAR

Changes  view on Meta::CPAN



0.42    2014-10-31  Released-By: PERLANCAR

	- Tweak help message: show --subcommands when program has
	  subcommands and doesn't specify one.


0.41    2014-10-30  Released-By: PERLANCAR

        - Add support for streaming input and output.


0.40    2014-10-28  Released-By: PERLANCAR

        [BUG FIXES]

        - Forgot to return response (when status is not 2xx and format is text).

        - Avoid perl undef warning.

Changes  view on Meta::CPAN

0.31    2014-09-17  Released-By: PERLANCAR

	- [Bugfix] Didn't set default value of args (from default property
	  of arg spec or schema default).

	- Tweak die string.


0.30    2014-09-16  Released-By: PERLANCAR

	- Handle output paging and streaming output (functionality moved from
          Perinci::CmdLine).


0.29    2014-09-11  Released-By: PERLANCAR

	- Handle arguments with cmdline_src=stdin_line and is_password
	  (Rinci 1.1.53).


0.28     2014-09-05  Released-By: PERLANCAR

lib/Perinci/CmdLine/Base.pm  view on Meta::CPAN


            ||
            # then by name
            ($a cmp $b)
        } keys %$args_p) {
            #log_trace("TMP: handle cmdline_src for arg=%s", $an);
            my $as = $args_p->{$an};
            my $src = $as->{cmdline_src};
            my $type = $as->{schema}[0]
                or die "BUG: No schema is defined for arg '$an'";
            # Riap::HTTP currently does not support streaming input
            my $do_stream = $as->{stream} && $url !~ /^https?:/;
            if ($src) {
                die [531,
                     "Invalid 'cmdline_src' value for argument '$an': $src"]
                    unless $src =~ /\A(stdin|file|stdin_or_files?|stdin_or_args|stdin_line)\z/;
                die [531,
                     "Sorry, argument '$an' is set cmdline_src=$src, but type ".
                         "is not str/buf/array, only those are supported now"]
                    unless $do_stream || $type =~ /\A(str|buf|array)\z/; # XXX stdin_or_args needs array only, not str/buf

lib/Perinci/CmdLine/Base.pm  view on Meta::CPAN


=head2 $cmd->hook_format_result($r)

The hook is supposed to format result in C<$res->{res}> (an array).

All direct subclasses of PC:Base do the formatting here.

=head2 $cmd->hook_display_result($r)

The hook is supposed to display the formatted result (stored in C<$r->{fres}>)
to STDOUT. But in the case of streaming output, this hook can also set it up.

All direct subclasses of PC:Base do the formatting here.

=head2 $cmd->hook_after_run($r)

Called at the end of C<run()>, right before it exits (if C<exit> attribute is
true) or returns C<$r->{res}>. The hook has a chance to modify exit code or
result.

=head1 SPECIAL ARGUMENTS

lib/Perinci/CmdLine/Base.pm  view on Meta::CPAN


or each output (C<.out>) file there will also be a corresponding C<.meta> file
that contains information like: command-line arguments, PID, etc. Some notes:

Output directory must already exist, or Perinci::CmdLine will display a warning
and then skip saving output.

Data that is not representable as JSON will be cleansed using
L<Data::Clean::ForJSON>.

Streaming output will not be saved appropriately, because streaming output
contains coderef that will be called repeatedly during the normal displaying of
result.

=head2 PERINCI_CMDLINE_PLUGINS

String. A list of plugins to load at the start of program. If it begins with a
C>[> (opening square bracket), it will be assumed to be in JSON encoding:

 ["PluginName1",{"arg1name":"arg1val","arg2name":"arg2val",...},"PluginName2", ...]

t/suite.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More 0.98;
use Test::Perinci::CmdLine;

# put other modules here
pericmd_ok(
    class => 'Perinci::CmdLine::Lite',
    exclude_tags => [
        'tx',
        'validate-streaming-input',
        'validate-result',
        'validate-streaming-result',
    ],
);
done_testing;



( run in 0.246 second using v1.01-cache-2.11-cpan-4d50c553e7e )