The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MooseX::App - Write user-friendly command line apps with even less suffering

SYNOPSIS

In your base class:

  package MyApp;
  use MooseX::App qw(Config Color);
 
  has 'global_option' => (
      is            => 'rw',
      isa           => 'Bool',
      documentation => q[Enable this to do fancy stuff],
  );

Write multiple command classes:

  package MyApp::SomeCommand;
  use MooseX::App::Command;
  extends qw(MyApp);
  
  has 'some_option' => (
      is            => 'rw',
      isa           => 'Str',
      documentation => q[Very important option!],
  );
  
  sub run {
      my ($self) = @_;
      # Do something
  }

And then in some simple wrapper script:

 #!/usr/bin/env perl
 use MyApp;
 MyApp->new_with_command->run;

DESCRIPTION

MooseX-App is a highly customizeable helper to write user-friendly command-line applications without having to worry about most of the annoying things usually involved. Just take any existing Moose class, add a single line (use MooseX-App qw(PluginA PluginB ...)) and create one class for each command in an underlying namespace.

MooseX-App will then take care of

  • Finding, loading and initializing the command classes

  • Creating automated doucumentation

  • Reading and validating the command line options entered by the user

Read the Tutorial for getting started with a simple MooseX::App command line application.

METHODS

new_with_command

 my $myapp_command = MyApp->new_with_command();

This method reads the command line arguments from the user and tries to create a command object. If it fails it retuns a MooseX::App::Message::Envelope object holding an error message.

You can pass a hash of default params to new_with_command

 MyApp->new_with_command( %default );

FUNCTIONS

app_base

 app_base 'my_script';

Usually MooseX::App will take the name of the calling wrapper script to construct the programm name in various help messages. This name can be changed via the app_base function.

app_namespace

 app_namespace 'MyApp::Commands';

Usually MooseX::App will take the package name of the base class as the namespace for commands. This namespace can be changed.

PLUGINS

The behaviour of MooseX-App can be customized with plugins. To load a plugin just pass a list of plugin names after the use MooseX-App statement.

 use MooseX::App qw(PluginA PluginB);

Read the Writing MooseX-App Plugins documentation on how to create your own plugins.

SEE ALSO

MooseX::App::Cmd, MooseX::Getopt and App::Cmd

SUPPORT

Please report any bugs or feature requests to bug-moosex-app@rt.cpan.org, or through the web interface at http://rt.cpan.org/Public/Bug/Report.html?Queue=MooseX-App. I will be notified, and then you'll automatically be notified of progress on your report as I make changes.

AUTHOR

    Maroš Kollár
    CPAN ID: MAROS
    maros [at] k-1.com
    
    http://www.k-1.com

COPYRIGHT

MooseX::App is Copyright (c) 2012 Maroš Kollár.

This library is free software and may be distributed under the same terms as perl itself. The full text of the licence can be found in the LICENCE file included with this module.