# initialize framework and run tool use App::Tool::Base qw/ run /; run(); exit 0; # describe actions sub new :Action :Descriprion("Create new instance") :Argument(name) { # all arguments and options in plain hash my %opt = @_; # ... some useful code here }
App::Tool::Base is a simple framework for rapid tool creation.
Here word <tool> means command-line utility that can perform some actions, and has common command-line format:
<utility-name> <action> <arguments and options>
$ svn checkout $REPO/trunk . -r 888 $ apt-get install $DEB $ docker images
App::Tool::Base provides smart command-line options processing with some checks, and help message generation.
sub init :Action { ... some code ... } sub recalculate_everything :Action(refresh) { ... }
Registers attributed sub as action worker.
If action name is not defined, sub name will be used
sub init :Action :Hidden { ... some code ... }
Mark action as hidden.
Hidden actions is not shown in lists, but still can be executed.
sub init :Action :Description("Initialize workplace") { ... some code ... }
Provides brief worker description.
sub init :Action :Argument(name, "workplace name") { ... some code ... }
Declares that action has required positional argument
sub init :Action :Argument(name, "workplace name") :OptionalArgument(template, "name of template") { ... some code ... }
Declares that action has optional positional argument
sub init :Action :Argument(name, "workplace name") :Option("v|verbose=i", "verbosity level") { ... some code ... } Declares that action has getopt-style option
Process command-line options and execute action
Assemble and show usage info.
Show list of supported actions.
To install App::Tool::Base, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Tool::Base
CPAN shell
perl -MCPAN -e shell install App::Tool::Base
For more information on module installation, please visit the detailed CPAN module installation guide.