NAME

App::CLI::Plugin::InstallCallback - for App::CLI::Extension install callback module

VERSION

0.2

SYNOPSIS

# MyApp.pm
package MyApp;

use strict;
use base qw(App::CLI::Extension);

__PACKAGE__->load_plugins(qw(InstallCallback));

# MyApp/Hello.pm
package MyApp::Hello;
use strict;
use feature ":5.10.0";
use base qw(App::CLI::Command);

sub prerun {

    my($self, @args) = @_;
    say "prerun method!";
}

sub run {

    my($self, @args) = @_;
    say "run method!";
}

sub postrun {

    my($self, @args) = @_;
    say "postrun method!";
}

sub finish {

    my($self, @args) = @_;
    say "finish method!";
}

# myapp
#!/usr/bin/perl

use strict;
use MyApp;

MyApp->dispatch;

# execute
[kurt@localhost ~] myapp hello
prerun method!
run method!
postrun method!
finish method!

DESCRIPTION

App::CLI::Extension install callback module

In App::CLI, run set of non-execution method, perform the installation

prerun phase(if exists) -> run phase -> postrun phase(if exists) -> finish phase(if exists)

App::CLI::Command in a class that inherits the *prerun*, *postrun*, *finish* the run only if it defines a method

METHOD

new_callback

install new callback phase

Example:

$self->new_callback("some_phase");

add_callback

install new callback

Example:

$self->add_callback("some_phase", sub { my $self = shift; say "some_phase method" });
$self->add_callback("prerun", sub { my $self = shift; say "prerun method No.1" });
$self->add_callback("prerun", sub { my $self = shift; say "prerun method No.2" });

exec_callback

execute callback

Example:

$self->execute_callback("some_phase");
# some_phase method

$self->execute_callback("prerun");
# prerun method No.1
# prerun method No.2

SEE ALSO

App::CLI::Extension Class::Data::Accessor Sub::Install

AUTHOR

Akira Horimoto

COPYRIGHT AND LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Copyright (C) 2009 Akira Horimoto