The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!perl

use 5.010;
use strict;
use warnings;
use Log::Any '$log';

use Perinci::CmdLine;

our $VERSION = '1.24'; # VERSION

our %SPEC;

$SPEC{generate_usage} = {
    v => 1.1,
    args => {
        url => {
            summary => 'Riap URL to function, e.g. /Git/Bunch/backup_bunch',
            req => 1,
            pos => 0,
            schema => 'str*',
        },
    },
};
sub generate_usage {
    my %args = @_;
    # XXX schema
    my $url = $args{url} or return [400, "Please specify url"];
    #$log->errorf("TMP: url=%s", $url);

    my $progname = $url; $progname =~ s!.+/!!;
    my $cmd = Perinci::CmdLine->new(
        log_any_app => 0,
        program_name => $progname,
        url => $url,
    );
    $cmd->run_help;
    [200, "OK", ''];
}

my $cmd = Perinci::CmdLine->new(
    log_any_app => 0, # speed up start-up
    url => '/main/generate_usage',
);
delete $cmd->common_opts->{format};
delete $cmd->common_opts->{format_options};
$cmd->run;

# ABSTRACT: Display command-line usage of a Riap function
# PODNAME: peri-func-usage

__END__

=pod

=encoding UTF-8

=head1 NAME

peri-func-usage - Display command-line usage of a Riap function

=head1 VERSION

This document describes version 1.24 of peri-func-usage (from Perl distribution Perinci-CmdLine), released on 2014-08-27.

=head1 SYNOPSIS

From command-line:

 % peri-func-usage /Some/Module/somefunc
 % peri-func-usage --help

=head1 DESCRIPTION

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/Perinci-CmdLine>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-Perinci-CmdLine>.

=head1 BUGS

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

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.

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2014 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.

=cut