App-ParseCommandLineUtils

 view release on metacpan or  search on metacpan

script/parse-command-line  view on Meta::CPAN


use 5.010001;
use strict;
use warnings;

use Perinci::CmdLine::Any;

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2022-11-04'; # DATE
our $DIST = 'App-ParseCommandLineUtils'; # DIST
our $VERSION = '0.001'; # VERSION

my $cmdline = Perinci::CmdLine::Any->new(
    url => "/App/ParseCommandLineUtils/parse_command_line",
    program_name => "parse-command-line",
    read_config => 0,
    read_env => 0,
);

$cmdline->run;

# ABSTRACT: Parse a command-line using one of the Perl command-line parsing modules
# PODNAME: parse-command-line

__END__

=pod

=encoding UTF-8

=head1 NAME

parse-command-line - Parse a command-line using one of the Perl command-line parsing modules

=head1 VERSION

This document describes version 0.001 of parse-command-line (from Perl distribution App-ParseCommandLineUtils), released on 2022-11-04.

=head1 SYNOPSIS

B<parse-command-line> L<--help|/"--help, -h, -v"> (or L<-h|/"--help, -h, -v">, L<-?|/"--help, -h, -v">)

B<parse-command-line> L<--version|/"--version, -v"> (or L<-v|/"--version, -v">)

B<parse-command-line> [L<--format|/"--format=s">=I<name>|L<--json|/"--json">] [L<--module|/"--module=s">=I<str>] [L<--(no)naked-res|/"--naked-res">] [L<--page-result|/"--page-result">[=I<program>]|L<--view-result|/"--view-result">[=I<program>]] -- E<...

=head1 DESCRIPTION

This is mainly for testing.

=head1 OPTIONS

C<*> marks required options.

=head2 Main options

=over

=item B<--cmdline>=I<s>*

You can also feed command-line from standard input, to avoid having to escape if
specified as shell argument.


Can also be specified as the 1st command-line argument.

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

Default value:

 "Text::ParseWords"

Valid values:

 ["Complete::Bash","Parse::CommandLine","Parse::CommandLine::Regexp","Text::ParseWords"]

=back

=head2 Output options

=over

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

Choose output format, e.g. json, text.

Default value:

 undef

Output can be displayed in multiple formats, and a suitable default format is
chosen depending on the application and/or whether output destination is
interactive terminal (i.e. whether output is piped). This option specifically
chooses an output format.


=item B<--json>

Set output format to json.

=item B<--naked-res>

When outputing as JSON, strip result envelope.

Default value:

 0

By default, when outputing as JSON, the full enveloped result is returned, e.g.:

 [200,"OK",[1,2,3],{"func.extra"=>4}]

The reason is so you can get the status (1st element), status message (2nd
element) as well as result metadata/extra result (4th element) instead of just
the result (3rd element). However, sometimes you want just the result, e.g. when
you want to pipe the result for more post-processing. In this case you can use
C<--naked-res> so you just get:

 [1,2,3]




( run in 1.509 second using v1.01-cache-2.11-cpan-39bf76dae61 )