App-PerinciUtils

 view release on metacpan or  search on metacpan

script/wrap-with-perinci-sub-wrapper  view on Meta::CPAN

    summary => 'Wrap subroutine with Perinci::Sub::Wrapper',
    description => <<'_',

This script is useful for testing Perinci::Sub::Wrapper. You specify input Rinci
metadata either using `--meta` or using `--url` to get it from Riap URL.

You then can show the code generated by the wrapper using `--show-code` (`-c`).

Or, you can call the wrapped function with one or more sets of arguments, by
supplying `--code` and one of: `--args`, `--multiple-args`, `--args-file`, or
`--multiple-args-file`.

_
    args_rels => {
        'req_one&' => [
            [qw/meta url/],
        ],
        # XXX code is not required if user uses url
        'choose_one&' => [
            [qw/args args_file multiple_args multiple_args_file/],
        ],
        # XXX: args, multiple_args, args_file, multiple_args_file only required if none of
        #'req_dep_any&' => [
        #    [],
        #],
    },
    args => {
        meta => {
            summary => 'Specify function metadata',
            schema => 'hash*',
            pos => 0,
            tags => ['category:meta-specification'],
        },
        url => {
            schema => 'str*',
            summary => 'Use function metadata from Riap URL',
            tags => ['category:meta-specification'],
        },
        # meta_file?
        code => {
            summary => 'Specify Perl code to wrap',
            schema => 'str*',
            tags => ['category:code-specification'],
        },

        args => {
            schema => ['hash*'],
            pos => 1,
            tags => ['category:argument-specification'],
        },
        multiple_args => {
            summary => 'Call with multiple args (array of args)',
            schema => ['array*', of=>'any'],
            tags => ['category:argument-specification'],
        },
        args_file => {
            schema => 'str*',
            summary => 'Retrieve args from file',
            description => <<'_',

JSON and YAML formats are supported. File type will be guessed from filename,
defaults to JSON.

_
            'x.schema.entity' => 'filename',
            tags => ['category:argument-specification'],
        },
        multiple_args_file => {
            schema => 'str*',
            summary => 'Retrieve multiple args from file',
            description => <<'_',

This is like `args_file` except that for multiple args. Content must be an
array.

_
            'x.schema.entity' => 'filename',
            tags => ['category:argument-specification'],
        },
        args_file_type => {
            schema => ['str*', in=>[qw/json yaml/]],
            summary => 'Give hint for args file type',
            tags => ['category:argument-specification'],
        },

        wrap => {
            schema => ['bool*', is=>1],
            default => 1,
            tags => ['category:wrapping'],
        },

        show_meta => {
            summary => "Don't call sub or wrap, show normalized metadata (before wrapping) only",
            schema => ['bool', is=>1],
            tags => ['category:action-selection'],
        },
        show_wrap_meta => {
            summary => "Don't call sub, show generated metadata after wrapping only",
            schema => ['bool', is=>1],
            tags => ['category:action-selection'],
        },
        show_wrap_code => {
            summary => "Don't call sub, show generated wrapper code only",
            schema => ['bool', is=>1],
            cmdline_aliases => {c=>{}},
            tags => ['category:action-selection'],
        },
        args_with_result => {
            summary => "Show args alongside with call result",
            description => <<'_',

The default is to show the call result only.

_
            schema => ['bool', is=>1],
            cmdline_aliases => {d=>{}},
            tags => ['category:output'],
        },
        with_debug => {
            summary => 'Generate wrapper with debug on',
            description => <<'_',

script/wrap-with-perinci-sub-wrapper  view on Meta::CPAN


=head1 VERSION

This document describes version 0.112 of wrap-with-perinci-sub-wrapper (from Perl distribution App-PerinciUtils), released on 2019-01-20.

=head1 SYNOPSIS

Usage:

 % wrap-with-perinci-sub-wrapper [options] [meta] [args]

=head1 DESCRIPTION

This script is useful for testing Perinci::Sub::Wrapper. You specify input Rinci
metadata either using C<--meta> or using C<--url> to get it from Riap URL.

You then can show the code generated by the wrapper using C<--show-code> (C<-c>).

Or, you can call the wrapped function with one or more sets of arguments, by
supplying C<--code> and one of: C<--args>, C<--multiple-args>, C<--args-file>, or
C<--multiple-args-file>.

=head1 OPTIONS

C<*> marks required options.

=head2 Action selection options

=over

=item B<--show-meta>

Don't call sub or wrap, show normalized metadata (before wrapping) only.

=item B<--show-wrap-code>, B<-c>

Don't call sub, show generated wrapper code only.

=item B<--show-wrap-meta>

Don't call sub, show generated metadata after wrapping only.

=back

=head2 Argument specification options

=over

=item B<--args-file-type>=I<s>

Give hint for args file type.

Valid values:

 ["json","yaml"]

=item B<--args-file>=I<filename>

Retrieve args from file.

JSON and YAML formats are supported. File type will be guessed from filename,
defaults to JSON.


=item B<--args-json>=I<s>

See C<--args>.

=item B<--args>=I<s>

=item B<--multiple-args-file>=I<filename>

Retrieve multiple args from file.

This is like `args_file` except that for multiple args. Content must be an
array.


=item B<--multiple-args-json>=I<s>

Call with multiple args (array of args) (JSON-encoded).

See C<--multiple-args>.

=item B<--multiple-args>=I<s>

Call with multiple args (array of args).

=back

=head2 Code specification options

=over

=item B<--code>=I<s>

Specify Perl code to wrap.

=back

=head2 Configuration options

=over

=item B<--config-path>=I<filename>

Set path to configuration file.

Can be specified multiple times.

=item B<--config-profile>=I<s>, B<-P>

Set configuration profile to use.

=item B<--no-config>, B<-C>

Do not use any configuration file.

=back

=head2 Environment options



( run in 2.169 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )