logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

MooX::Options::Manual::MooXCmd - Manage your tools with MooX::Cmd

Author

       celogeek <me@celogeek.com>

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/perl

         use strict; use warnings all => "FATAL";

         use MyTool;

         MyTool->new_with_cmd->execute

       "MooX::Options" improves the help message to display automatically the subcommands.

Name

       MooX::Options::Manual::MooXCmd - Manage your tools with MooX::Cmd

See Also

       MooX::Options

       MooX::Cmd

       MooX::ConfigFromFile

       MooX::Log::Any

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} );
             ...
         }

See Also