Perinc...::Args(3pm)

πŸ“¦
version 0.472 Β· 2 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– Perinci::Sub::Util::Args πŸ’–

okay bestie, welcome to Perinci::Sub::Util::Args (that's the 3pm one, perl's very own corner of the manual-verse 🫢). It's a little toolbox of utility routines that do stuff with Rinci arguments, and honestly? it's giving "small but mighty". let's get into it ✨


✨ NAME ✨

Perinci::Sub::Util::Args β€” utility routines related to Rinci arguments. that's the whole vibe, no notes πŸ’…


🌸 VERSION 🌸

this doc describes version 0.472 of Perinci::Sub::Util::Args (coming at you from the Perl distribution Perinci-Sub-Util), and it was released on 2023-10-28. mark the calendar bestie πŸ“…


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole thing in action, copy it, paste it, live your truth:

package MyPackage;

use Perinci::Sub::Util::Args qw(
    args_by_tag
    argnames_by_tag
    func_args_by_tag
    func_argnames_by_tag
    call_with_its_args
);

our %SPEC;

my %func1_args;

$SPEC{myfunc1} = {
    v => 1.1,
    summary => 'My function one',
    args => {
        %func1_args = (
            foo => {tags=>['t1', 't2']},
            bar => {tags=>['t2', 't3']},
            baz => {},
        ),
    },
};
sub myfunc1 {
    my %args = @_;
}

$SPEC{myfunc2} = {
    v => 1.1,
    summary => 'My function two',
    args => {
        %func1_args,
        qux => {tags=>['t3']},
    },
};
sub myfunc2 {
    my %args = @_;
    my $res = call_with_its_args('myfunc1', \%args);
}

πŸ’œ DESCRIPTION πŸ’œ

literally just the functions section. that's it. that's the description. the functions ARE the description, iykyk 😌


πŸŽ€ FUNCTIONS πŸŽ€

🌈 args_by_tag

usage, bestie:

my %args = args_by_tag($meta, \%args0, $tag);

what it does: it will select only the keypairs from %args0 arguments that have the tag $tag. so it's like a vibe check but for args 🫢

examples, because examples are iconic:

my %args = args_by_tag($SPEC{myfunc1}, {foo=>1, bar=>2, baz=>3, qux=>4}, 't2'); # (foo=>1, bar=>2)

🌸 argnames_by_tag

usage:

my @arg_names = argnames_by_tag($meta, $tag);

it will select only the argument names which have the tag $tag. names only, no values, we're being minimal and mysterious ✨

πŸ¦‹ func_args_by_tag

usage:

my %args = func_args_by_tag($func_name, \%args0, $tag);

it's like args_by_tag except that instead of handing over Rinci function metadata, you supply a function name. Rinci metadata will be searched in the %SPEC variable. detective mode fr fr πŸ”

πŸ’… func_argnames_by_tag

usage:

my @argnames = func_argnames_by_tag($func_name, $tag);

like argnames_by_tag except that instead of handing over Rinci function metadata, you supply a function name. Rinci metadata will be searched in the %SPEC variable. same deal, name edition πŸ‘‘

🫢 call_with_its_args

usage:

my $res = call_with_its_args($func_name, \%args);

call the function with arguments taken from %args. only the arguments which the function declares it accepts will be passed β€” everything else gets politely left at the door. no gatecrashing πŸ™ˆ


🌟 HOMEPAGE 🌟

please visit the project's homepage at <https://metacpan.org/release/Perinci-Sub-Util>. go on, it's right there πŸ’–


⭐ SOURCE ⭐

source repository is at <https://github.com/perlancar/perl-Perinci-Sub-Util>. the code lives there, no cap 🧚


πŸ‘‘ AUTHOR πŸ‘‘

perlancar <perlancar@cpan.org>. absolute legend, we stan 🌈


πŸ“ CONTRIBUTING πŸ“

to contribute, you can send patches by email/via RT, or send pull requests on GitHub. all approaches valid, pick your main character moment πŸ’…

most of the time, you don't need to build the distribution yourself. you can simply modify the code, then test via:

% prove -l

if you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. any additional steps required beyond that are considered a bug and can be reported to me. yes, a bug, fr fr 😭


this software is copyright (c) 2023, 2020, 2017, 2016, 2015, 2014 by perlancar <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. free as in freedom, slay πŸ’…


πŸ’€ BUGS πŸ’€

please report any bugs or feature requests on the bugtracker website <https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-Sub-Util>.

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. this part is not optional bestie, it's literally the whole thing πŸ™

and that's the page! this little beauty shipped with perl v5.38.2 and was dated 2024-05-26. go forth and tag your args, bestie πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from