Perinci-CmdLine

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


1.909.0  2021-10-01  Released-By: PERLANCAR; Urgency: medium

	 - Add POD: Perinci::CmdLine::Manual::HowTo::Debugging.


1.811.0  2018-03-17  Released-By: PERLANCAR

         - Synchronize version with latest Perinci::CmdLine::Lite.

         - [doc] Add FAQ section "Progress Indicator", add example for streaming
           a file in output, add list of tutorial pages to fill in later.


1.77    2017-07-31  Released-By: PERLANCAR

        - Synchronize version with latest Perinci::CmdLine::Lite.

	- Update documentation, replace mention of Log::Any with Log::ger.


lib/Perinci/CmdLine/Manual/FAQ.pod  view on Meta::CPAN

riap+unix, riap+pipe). http/https and local are supported though.

=item * Extra stuffs that Perinci::Sub::Wrapper adds

PC::Classic uses function wrapper to automatically adds argument validation,
dependency checking, and so on. However, this adds too much overhead so PC:Lite
avoids it and do some of the stuffs by itself to avoid the overhead.

PC:Lite does argument validation, as well as dependency checking. But there are
other stuffs that Perinci::Sub::Wrapper adds that are not available, including:
result validation, validation of input stream (streaming argument) as well as
output stream (streaming result).

=item * Color themes

=item * Undo

=item * I18N

=item * The following environment variables

 PERINCI_CMDLINE_COLOR_THEME

lib/Perinci/CmdLine/Manual/HowTo/99Examples.pod  view on Meta::CPAN


 % cat file.txt
 This is content of file.txt
 % cat file.txt | cmd
 arg is 'This is content of file.txt'

If your function argument is an array, array of lines will be provided to your
function.

Note that this will glob the whole content of input into memory. If you want
streaming, see the next section.

=head2 Accept streaming input

To accept streaming input, you specify one or more of your arguments as C<<
stream=>1 >>. Also, these arguments need to specify their source either from
file, STDIN, or STDIN/files, by setting C<< cmdline_src =>
file|stdin|stdin_or_files >>, because otherwise, just receiving value from
command-line option like C<--arg val> is not very interesting :-). You will
receive your function argument as a coderef which you can call repeatedly until
input is exhausted (at the point of which the coderef will return undef).

 $SPEC{perl_wc} = {
     v => 1.1,
     args => {

lib/Perinci/CmdLine/Manual/HowTo/99Examples.pod  view on Meta::CPAN


You can also do this on a per-result basis, by adding C<cmdline.default_format>
attribute in your result metadata, e.g.:

 sub foo {
     [200, "OK", [[1,2], [3,4], [5,6]], {'cmdline.default_format'=>'text-simple'}];
 }

=head2 Streaming output

To produce streaming output, set C<< stream=>1 >> in C<result> spec in function
metadata. Then in your function, return a subroutine reference that will allow
caller to read data from.

 $SPEC{nat} = {
     v => 1.1,
     summary => 'Generate an infinite sequence of natural numbers',
     args => {},
     result => {
         stream => 1,
         schema => 'str*',



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