=head1 NAME
MooX::Options::Manual::MooXCmd - Manage your tools with MooX::Cmd
=head1 SYNOPSIS
package MyTool;
use strict; use warnings all => "FATAL";
use Class::Load qw(load_class);
use DBIx::LogAny;
use Moo;
use MooX::Cmd => with_config_from_file; # enable MooX::Cmd driven _build_config_prefixes
use MooX::Options => with_config_from_file; # enable --config-files and --config-prefix
with "MooX::Log::Any";
option option log_adapter => (is => "ro", required => 1, trigger => 1, json => 1 );
option connection => (is => "ro", required => 1, json => 1);
sub _trigger_log_adapter { my ( $self, $opts ) = @_; load_class("Log::Any::Adapter")->set( @{$opts} ); }
sub execute {
my $self = shift;
my $conn = $self->connection;
$conn->[3] ||= {};
$conn->[3]->{dbix_la_logger} = $self->log;
my $dbh = DBIx::LogAny->connect( @{$conn} );
...
}
=head1 DESCRIPTION
L<MooX::Cmd> gives you an easy way to organize your tools into many subcommands.
We can take 'git' as a example.
git checkout [params]
git commit [params]
L<MooX::ConfigFromFile> gives one a more easy way to configure recurring or complex parameters.
C<MooX::ConfigFromFile> finds and loads several configuration files based on your setup. Please
read L<MooX::ConfigFromFile::Role> carefully to learn which files from which location are
loaded and how this can tuned.
L<MooX::Options> plays natively with these tools and they do with C<MooX::Options>.
$ cat bin/mytool
#!/opt/myprj/bin/perl
use strict; use warnings all => "FATAL";
use MyTool;
MyTool->new_with_cmd->execute
C<MooX::Options> improves the help message to display automatically the subcommands.
=head1 SEE ALSO
L<MooX::Options>
L<MooX::Cmd>
L<MooX::ConfigFromFile>
L<MooX::Log::Any>
=head1 AUTHOR
celogeek <me@celogeek.com>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by celogeek <me@celogeek.com>.
This software is copyright (c) 2017 by Jens Rehsack.
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