![]() ![]() If disabled all extra parameters will be copied to the extra_argv attribute. If strict is enabled the program will terminate with an error message if superfluous/unknown positional parameters are supplied. app_fuzzy app_fuzzy 1 # defaultĮnables fuzzy matching of commands and attributes. This name can be changed via the app_base function. Usually MooseX::App will take the name of the calling wrapper script to construct the program name in various help messages. app_base app_base 'my_script' # Defaults to $0 These options may be used to alter the default behaviour of MooseX-App. Helper method to instantiate the command class for the given command. initialize_command_class my $obj = MyApp->initialize_command_class($command_name,%default) However, if you do so you must take care of propper encoding yourself. Optionally you can pass a custom ARGV to this constructor my $obj = MyApp->new_with_command( ARGV => ) You can pass a hash of default/fallback params to new_with_command my $obj = MyApp->new_with_command(%default) If it fails it returns a MooseX::App::Message::Envelope object holding an error message. This constructor reads the command line arguments and tries to create a command class instance. METHODS new_with_command my $myapp_command = MyApp->new_with_command() Read the Tutorial for getting started with a simple MooseX::App command line application. HashRef: Specify multiple key value pairs ('-opt key=value -opt key2=value2', also see app_permute) The following type constraints are supported:ĪrrayRef: Specify multiple values ('-opt value1 -opt value2', also see app_permute and cmd_split) Moose type constraints help MooseX::App to construct helpful error messages and parse in a meaningful way. Positional parameters are defined with the 'parameter' keyword parameter 'some_option' => (Īll keywords are imported by Moosex::App (in the app base class) and MooseX::App::Command (in the command class) or MooseX::App::Simple (single class application).įurthermore, all options and parameters can also be supplied via %ENV option 'some_option' => (Ĭmd_env => 'SOME_OPTION', # sets the env key ![]() However such options must have a Boolean type constraint. Single letter options are treated as flags and may be combined with each other. Traits =>, # Load extra metaclassĬmd_type => 'option', # Set attribute type This is equivalent to has 'some_option' => ( Provide helpful error messages if user input cannot be validated (either missing or wrong attributes or Moose type constraints not satisfied) or if the user requests help.Ĭommandline options are defined using the 'option' keyword which accepts the same attributes as Moose' 'has' keyword. Read, encode and validate the command line options and positional parameters entered by the user from and %ENV (and possibly prompt the user for additional parameters see MooseX::App::Plugin::Term) Options and positional parameters can be defined as simple Moose accessors using the option and parameter keywords respectively.įind, load and initialise the command classes (see MooseX::App::Simple for single class/command applications)Ĭreate automated help and documentation from modules POD as well as attributes metadata and type constraints ) ) and create one class for each command in an underlying namespace. Just take any existing Moose class, add a single line ( use MooseX-App qw(PluginA PluginB. 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. help -usage -? Prints this usage information. Some_parameter Some parameter that you need to supply Īnother_command Description of another command global_option Enable this to do fancy stuff Use MooseX::App::Command # important (also imports Moose)Įxtends qw(MyApp) # optional, only if you want to use global options from base classĪnd then you need a simple wrapper script (called eg. Packackes in the namespace may be deeply nested. Write multiple command classes (If you have only a single command class you should use MooseX::App::Simple instead). MooseX::App - Write user-friendly command line apps with even less suffering SYNOPSISĭocumentation => q,
0 Comments
Leave a Reply. |