MooX-Options
view release on metacpan or search on metacpan
get '/suits' => sub {
$my $reqh = Suitable::Web::Request::Handler->new( attr => config->{suit_attr} );
$reqh->all_suits;
};
dance;
1;
Of course there more ways to to it, [Jedi](https://metacpan.org/pod/Jedi) or [Catalyst](https://metacpan.org/pod/Catalyst) shall be fine, either.
## Rename negativable into negatable
Since users stated that `negativable` is not a reasonable word, the flag is
renamed into negatable. Those who will 2020 continue use negativable might
or might not be warned about soon depreciation.
## Replace Locale::TextDomain by MooX::Locale::Passthrough
[Locale::TextDomain](https://metacpan.org/pod/Locale::TextDomain) is broken (technically and functionally) and causes a
lot of people to avoid `MooX::Options` or hack around. Both is unintened.
So introduce [MooX::Locale::Passthrough](https://metacpan.org/pod/MooX::Locale::Passthrough) to allow any vendor to add reasonable
localization, eg. by composing [MooX::Locale::TextDomain::OO](https://metacpan.org/pod/MooX::Locale::TextDomain::OO) into it's
solution and initialize the localization in a reasonable way.
## Make lazy loaded features optional
Since some features aren't used on a regular basis, their dependencies have
been downgraded to `recommended` or `suggested`. The optional features are:
- autosplit
This feature allowes one to split option arguments at a defined character and
always return an array (implicit flag `repeatable`).
option "search_path" => ( is => "ro", required => 1, autosplit => ":", format => "s" );
However, this feature requires following modules are provided:
- [Data::Record](https://metacpan.org/pod/Data::Record)
- [Regexp::Common](https://metacpan.org/pod/Regexp::Common)
- 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 _handles_.
Handling JSON formatted arguments requires any of those modules
are loded:
- [JSON::MaybeXS](https://metacpan.org/pod/JSON::MaybeXS)
- [JSON::PP](https://metacpan.org/pod/JSON::PP) (in Core since 5.14).
## 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.
# IMPORTED METHODS
The list of the methods automatically imported into your class.
## new\_with\_options
It will parse your command line params and your inline params, validate and call the `new` method.
myTool --str=ko
t->new_with_options()->str # ko
t->new_with_options(str => 'ok')->str #ok
## option
The `option` keyword replaces the `has` method and adds support for special options for the command line only.
See ["OPTION PARAMETERS"](#option-parameters) for the documentation.
## 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
## 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
## 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 0.606 second using v1.01-cache-2.11-cpan-71847e10f99 )