NAME

App::Base::Script - A truly lazy person's tool for writing self-documenting, self-monitoring scripts

SYNOPSIS

package MyScript;

use Moose;
with 'App::Base::Script';

sub documentation { return 'This is a script.'; }

sub script_run {
    my $self = shift;
    # do something
    return 0;
}

no Moose;
__PACKAGE__->meta->make_immutable;

package main;

exit MyScript->new()->run();

DESCRIPTION

App::Base::Script builds on App::Base::Script::Common and provides common infrastructure that is useful for writing scripts.

REQUIRED SUBCLASS METHODS

See also, App::Base::Script::Common "REQUIRED METHODS"

script_run($self, @ARGS)

The code that actually executes the meat of the script. When a App::Base::Script is invoked by calling run(), all of the relevant options parsing and error handling is performed and then control is handed over to the script_run() method. The return value of script_run() is returned as the return value of run().

METHODS

The new() method

(See App::Base::Script::Common::new)

error

Handles errors generated by the script. This results in a call to App::Base::Script::Common::__error, which exits.

USAGE

Invocation

Invocation of a App::Base::Script-based script is accomplished as follows:

-

Define a class that implements the App::Base::Script interface (using 'with App::Base::Script')

-

Instantiate an object of that class via new()

-

Run the script by calling run(). The return value of run() is the exit status of the script, and should typically be passed back to the calling program via exit()

Options handling

(See App::Base::Script::Common, "Options handling")

LICENSE AND COPYRIGHT

Copyright (C) 2010-2014 Binary.com

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.