MooX-Options
view release on metacpan or search on metacpan
lib/MooX/Options.pm view on Meta::CPAN
So introduce L<MooX::Locale::Passthrough> to allow any vendor to add reasonable
localization, eg. by composing L<MooX::Locale::TextDomain::OO> into it's
solution and initialize the localization in a reasonable way.
=head2 Make lazy loaded features optional
Since some features aren't used on a regular basis, their dependencies have
been downgraded to C<recommended> or C<suggested>. The optional features are:
=over 4
=item autosplit
This feature allowes one to split option arguments at a defined character and
always return an array (implicit flag C<repeatable>).
option "search_path" => ( is => "ro", required => 1, autosplit => ":", format => "s" );
However, this feature requires following modules are provided:
=over 4
=item *
L<Data::Record>
=item *
L<Regexp::Common>
=back
=item json format
This feature allowes one to invoke a script like
$ my-tool --json-attr '{ "gem": "sapphire", "color": "blue" }'
It might be a reasonable enhancement to I<handles>.
Handling JSON formatted arguments requires any of those modules
are loded:
=over 4
=item *
L<JSON::MaybeXS>
=item *
L<JSON::PP> (in Core since 5.14).
=back
=back
=head2 Decouple autorange and autosplit
Until 4.023, any option which had autorange enabled got autosplit enabled, too.
Since autosplit might not work correctly and for a reasonable amount of users
the fact of
$ my-tool --range 1..5
is all they desire, autosplit will enabled only when the dependencies of
autosplit are fulfilled.
=head1 IMPORTED METHODS
The list of the methods automatically imported into your class.
=head2 new_with_options
It will parse your command line params and your inline params, validate and call the C<new> method.
myTool --str=ko
t->new_with_options()->str # ko
t->new_with_options(str => 'ok')->str #ok
=head2 option
The C<option> keyword replaces the C<has> method and adds support for special options for the command line only.
See L</OPTION PARAMETERS> for the documentation.
=head2 options_usage | --help
It displays the usage message and returns the exit code.
my $t = t->new_with_options();
my $exit_code = 1;
my $pre_message = "str is not valid";
$t->options_usage($exit_code, $pre_message);
This method is also automatically fired if the command option "--help" is passed.
myTool --help
=head2 options_man | --man
It displays the manual.
my $t = t->new_with_options();
$t->options_man();
This is automatically fired if the command option "--man" is passed.
myTool --man
=head2 options_short_usage | --usage
It displays a short version of the help message.
my $t = t->new_with_options();
$t->options_short_usage($exit_code);
This is automatically fired if the command option "--usage" is passed.
myTool --usage
( run in 1.788 second using v1.01-cache-2.11-cpan-71847e10f99 )