Perl x Open Food Facts Hackathon: Paris, France - May 24-25 Learn more

SYNOPSIS

# 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
}

DESCRIPTION

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.

ATTRIBUTE HANDLERS

:Action

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

:Hidden

sub init :Action
:Hidden
{ ... some code ... }

Mark action as hidden.

Hidden actions is not shown in lists, but still can be executed.

:Description

sub init :Action
:Description("Initialize workplace")
{ ... some code ... }

Provides brief worker description.

:Argument

sub init :Action
:Argument(name, "workplace name")
{ ... some code ... }

Declares that action has required positional argument

:OptionalArgument

sub init :Action
:Argument(name, "workplace name")
:OptionalArgument(template, "name of template")
{ ... some code ... }

Declares that action has optional positional argument

:Option

sub init :Action
:Argument(name, "workplace name")
:Option("v|verbose=i", "verbosity level")
{ ... some code ... }
Declares that action has getopt-style option

FUNCTIONS

run

Process command-line options and execute action

BUILT-IN ACTIONS

help

Assemble and show usage info.

LIST

Show list of supported actions.