MooX::Options::Manual::MooXCmd(3pm)

MooX::Options::Manual::MooXCmd3pm

Manage your tools with moox::cmd

Usage

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

Overview

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.

Releases

6 releases since Debian 8 (Jessie); the text changed 5 times.

  1. 8
  2. 9
  3. 10
  4. 11
  5. 12
  6. 13

Author

celogeek <[email protected]>

From libmoox-options-perl 4.103-5 in Debian 13 (Trixie). Parsed by carta from the page's man source.