App::Rad

Rapid (and easy!) creation of command line applications
Download

App::Rad Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Breno G. de Oliveira
  • Publisher web site:
  • http://search.cpan.org/~garu/

App::Rad Tags


App::Rad Description

Rapid (and easy!) creation of command line applications App::Rad is a Perl module that aims to be a simple yet powerful framework for developing your command-line applications. It can easily transform your Perl one-liners into reusable subroutines than can be called directly by the user of your program.It also tries to provide a handy interface for your common command-line tasks.SYNOPSIS ^This is your smallest working application (let's call it myapp.pl) use App::Rad; App::Rad->run();That's it, your program already works and you can use it directly via the command line (try it!) $ ./myapp.pl Usage: myapp.pl command Available Commands: help show syntax and available commandsNext, start creating your own functions (e.g.) inside myapp.pl: sub hello { return "Hello, World!"; }And now your simple command line program myapp.pl has a 'hello' command! $ ./myapp.pl Usage: myapp.pl command Available Commands: hello help show syntax and available commands $ ./myapp.pl hello Hello, World!You could easily add a customized help message for your command through the 'Help()' attribute: sub hello :Help(give a nice compliment) { return "Hello, World!"; }And then, as expected: $ ./myapp.pl Usage: myapp.pl command Available Commands: hello give a nice compliment help show syntax and available commandsApp::Rad also lets you expand your applications, providing a lot of flexibility for every command, with embedded help, argument and options parsing, configuration file, default behavior, and much more: use App::Rad; App::Rad->run(); sub setup { my $c = shift; $c->register_commands( { foo => 'expand your foo!', bar => 'have a drink! arguments: --drink=DRINK', }); } sub foo { my $c = shift; $c->load_config('myapp.conf'); return 'foo expanded to ' . baz() * $c->config->{'myfoo'}; } # note that 'baz' was not registered as a command, # so it can't be called from the outside. sub baz { rand(10) } sub bar { my $c = shift; if ( $c->options->{'drink'} ) { return 'you asked for a ' . $c->options->{'drink'}; } else { return 'you need to ask for a drink'; } }You can try on the command line: $ ./myapp.pl Usage: myapp.pl command Available Commands: bar have a drink! arguments: --drink=DRINK foo expand your foo! help show syntax and available commands $ ./myapp.pl bar --drink=martini you asked for a martini Requirements: · Perl


App::Rad Related Software