DESCRIPTION

MooseX-App is a highly customisable 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. Options and positional parameters can be defined as simple Moose accessors.

MooseX-App will then

Find, load and initialise the command classes (see MooseX-App-Simple for single command applications)

Create automated help and documentation from modules POD as well as attributes metadata and type constraints

Read, encode and validate the command line options and positional parameters entered by the user from @ARGV and %ENV (and possibly prompt the user for additional parameters see MooseX-App-Plugin-Term)

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 constructor reads the command line arguments and tries to create a command class instance. If it fails it retuns a MooseX::App::Message::Envelope object holding an error message.

You can pass a hash of default/fallback params to new_with_command

my $obj = MyApp->new_with_command(%default);

initialize_command_class

my $obj = MyApp->initialize_command_class($command_name,%default);

Helper method to instantiate the command class for the given command.

GLOBAL OPTIONS

app_base

app_base 'my_script'; # Defaults to $0

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

app_fuzzy

app_fuzzy(1); # default
OR
app_fuzzy(0);

Enables fuzzy matching of commands and attributes. Is turned on by default.

app_strict

app_strict(0); # default
OR
app_strict(1);

If strict is enabled the program will terminate with an error message if superfluous/unknown positional parameters are supplied. If disabled all extra parameters will be copied to the extra_argv attribute.

The command_strict config in the command classes allows one to set this option individually for each command in the respective command class.

app_prefer_commandline

app_prefer_commandline(0); # default
or
app_prefer_commandline(1);

Specifies if parameters/options supplied via @ARGV,%ENV should take precedence over arguments passed to new_with_command.

CAVEATS & KNOWN BUGS

Startup time may be an issue - escpecially if you load many plugins. If you do not require the functionality of plugins and ability for fine grained customisation (or Moose for that matter) then you should probably use MooX::Options or MooX::Cmd.

In some cases - especially when using non-standard class inheritance - you may end up with command classes lacking the help attribute. In this case you need to include the following line in your base class

with qw(MooseX::App::Role::Common);

SEE ALSO

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