<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    Perinci::CmdLine::Classic - Rinci/Riap-based command-line application
    framework

VERSION
    This document describes version 1.812 of Perinci::CmdLine::Classic (from
    Perl distribution Perinci-CmdLine-Classic), released on 2018-05-20.

SYNOPSIS
    In "gen-random-num" script:

     use Perinci::CmdLine::Classic;

     our %SPEC;

     $SPEC{gen_random_num} = {
         v =&gt; 1.1,
         summary =&gt; 'Generate some random numbers',
         args =&gt; {
             count =&gt; {
                 summary =&gt; 'How many numbers to generate',
                 schema =&gt; ['int*' =&gt; min=&gt;0],
                 default =&gt; 1,
                 cmdline_aliases=&gt;{n=&gt;{}},
                 req =&gt; 1,
                 pos =&gt; 0,
             },
             min =&gt; {
                 summary =&gt; 'Lower limit of random number',
                 schema =&gt; 'float*',
                 default =&gt; 0,
             },
             max =&gt; {
                 summary =&gt; 'Upper limit of random number',
                 schema =&gt; 'float*',
                 default =&gt; 1,
             },
         },
         result_naked =&gt; 1,
     };
     sub gen_random_num {
         my %args = @_;

         my @res;
         for (1..$args{count}) {
             push @res, $args{min} + rand()*($args{max}-$args{min});
         }
         \@res;
     }

     Perinci::CmdLine::Classic-&gt;new(url =&gt; '/main/gen_random_num')-&gt;run;

    Run your script:

     % ./gen-random-num
     0.999473691060306

     % ./gen-random-num --min 1 --max 10 5
     1.27390166158969
     1.69077475473679
     8.97748327778684
     5.86943773494068
     8.34341298182493

    JSON output support out of the box:

     % ./gen-random-num -n3 --json
     [200,"OK (envelope added by Perinci::Access::Lite)",[0.257073684902029,0.393782991540746,0.848740540017513],{}]

    Automatic help message:

     % ./gen-random-num -h
     gen-random-num - Generate some random numbers

     Usage:
       gen-random-num --help (or -h, -?)
       gen-random-num --version (or -v)
       gen-random-num [options] [count]
     Options:
       --config-path=s     Set path to configuration file
       --config-profile=s  Set configuration profile to use
       --count=i, -n       How many numbers to generate (=arg[0]) [1]
       --format=s          Choose output format, e.g. json, text [undef]
       --help, -h, -?      Display this help message
       --json              Set output format to json
       --max=f             Upper limit of random number [1]
       --min=f             Lower limit of random number [0]
       --naked-res         When outputing as JSON, strip result envelope [0]
       --no-config         Do not use any configuration file
       --version, -v

    Automatic configuration file support:

     % cat ~/gen-random-num.conf
     count=5
     max=0.01

     % ./gen-random-num
     0.00105268954838724
     0.00701443611501844
     0.0021247476506154
     0.00813872824513005
     0.00752832346491306

    Automatic tab completion support:

     % complete -C gen-random-num gen-random-num
     % gen-random-num --mi&lt;tab&gt;

    See Perinci::CmdLine::Manual for details on other available features
    (subcommands, automatic formatting of data structures, automatic schema
    validation, dry-run mode, automatic POD generation, remote function
    support, automatic CLI generation, automatic --version, automatic HTTP
    API, undo/transactions, configurable output format, logging, progress
    bar, colors/Unicode, and more).

DESCRIPTION
    Perinci::CmdLine is a command-line application framework. It allows you
    to create full-featured CLI applications easily and quickly.

    See Perinci::CmdLine::Manual for more details.

    There is also a blog post series on Perinci::CmdLine tutorial:
    &lt;https://perlancar.wordpress.com/category/pericmd-tut/&gt;

    Perinci::CmdLine::Classic is the heavier backend implementation which
    supports some extra features currently not supported by the default
    backend implementation Perinci::CmdLine::Lite. These features come at
    some startup overhead cost and more dependencies. You normally should
    use Perinci::CmdLine::Any instead to be able to switch backend on the
    fly.

    Screenshots:

REQUEST KEYS
    See also Perinci::CmdLine::Base. Extra stuffs put by this module to the
    $r hash/stash.

    *   format_options =&gt; hash

RESULT METADATA
    All those supported by Perinci::CmdLine::Base, plus:

  x.hint.result_binary =&gt; bool
    If set to true, then when formatting to "text" formats, this class won't
    print any newline to keep the data being printed unmodified.

ATTRIBUTES
    All the attributes of Perinci::CmdLine::Base, plus:

  use_utf8 =&gt; BOOL
    From Term::App::Role::Attrs (please see its docs for more details).
    There are several other attributes added by the role.

  undo =&gt; BOOL (optional, default 0)
    Whether to enable undo/redo functionality. Some things to note if you
    intend to use undo:

    *   These common command-line options will be recognized

        "--undo", "--redo", "--history", "--clear-history".

    *   Transactions will be used

        "use_tx=&gt;1" will be passed to Perinci::Access, which will cause it
        to initialize the transaction manager. Riap requests begin_tx and
        commit_tx will enclose the call request to function.

    *   Called function will need to support transaction and undo

        Function which does not meet qualifications will refuse to be
        called.

        Exception is when subcommand is specified with "undo=&gt;0", where
        transaction will not be used for that subcommand. For an example of
        disabling transaction for some subcommands, see "bin/u-trash" in the
        distribution.

  undo_dir =&gt; STR (optional, default ~/.&lt;program_name&gt;/.undo)
    Where to put undo data. This is actually the transaction manager's data
    dir.

METHODS
    All the methods of Perinci::CmdLine::Base, plus:

ENVIRONMENT
    All the environment variables that Perinci::CmdLine::Base supports,
    plus:

  PERINCI_CMDLINE_COLOR_THEME =&gt; STR
    Can be used to set "color_theme".

  PROGRESS =&gt; BOOL
    Explicitly turn the progress bar on/off.

  COLOR =&gt; INT
    Please see Term::App::Role::Attrs.

  UTF8 =&gt; BOOL
    Please see Term::App::Role::Attrs.

HOMEPAGE
    Please visit the project's homepage at
    &lt;https://metacpan.org/release/Perinci-CmdLine-Classic&gt;.

SOURCE
    Source repository is at
    &lt;https://github.com/perlancar/perl-Perinci-CmdLine-Classic&gt;.

BUGS
    Please report any bugs or feature requests on the bugtracker website
    &lt;https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-CmdLine-Class
    ic&gt;

    When submitting a bug or request, please include a test-file or a patch
    to an existing test-file that illustrates the bug or desired feature.

SEE ALSO
    Perinci::CmdLine::Any, Perinci::CmdLine::Lite.

AUTHOR
    perlancar &lt;perlancar@cpan.org&gt;

COPYRIGHT AND LICENSE
    This software is copyright (c) 2018, 2017, 2016, 2015, 2014, 2013, 2012,
    2011 by perlancar@cpan.org.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.

</pre></body></html>