GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
MooX::Options::Manual::MooXCmd(3) User Contributed Perl Documentation MooX::Options::Manual::MooXCmd(3)

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

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

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.

MooX::Options

MooX::Cmd

MooX::ConfigFromFile

MooX::Log::Any

celogeek <me@celogeek.com>

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.

2017-08-16 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.