NAME
MooX::Options::Manual::MooXCmd - Manage your tools with MooX::Cmd
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_prefixesuse MooX::Options => with_config_from_file; # enable --config-files and --config-prefixwith "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} );...}
DESCRIPTION
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]
MooX::ConfigFromFile gives one a more easy way to configure recurring or complex parameters. "MooX::ConfigFromFile" finds and loads several configuration files based on your setup. Please read MooX::ConfigFromFile::Role carefully to learn which files from which location are loaded and how this can tuned.
MooX::Options plays natively with these tools and they do with "MooX::Options".
$ cat bin/mytool#!/opt/myprj/bin/perluse strict; use warnings all => "FATAL";use MyTool;MyTool->new_with_cmd->execute
"MooX::Options" improves the help message to display automatically the subcommands.
SEE ALSO
MooX::Options
MooX::Cmd
MooX::ConfigFromFile
MooX::Log::Any
AUTHOR
celogeek <[email protected]>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by celogeek <[email protected]>.
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.