Acrux
view release on metacpan or search on metacpan
lib/Acme/Crux.pm view on Meta::CPAN
=head2 exedir
my $exedir = $app->exedir;
Gets exedir value
=head2 handlers
my @names = $app->handlers;
Returns list of names of registered handlers
my @names_and_aliases = $app->handlers(1);
Returns list of aliases and names of registered handlers
=head2 lookup_handler
my $handler = $app->lookup_handler($name)
or die "Handler not found";
Lookup handler by name or aliase. Returns handler or undef while error
=head2 option, opt, getopt
my $value = $app->option("key");
Returns option value by key
my $options = $app->option;
Returns hash-ref structure to all options
See L</options>
=head2 orig
my $origin_args = $app->orig;
Returns hash-ref structure to all origin arguments
=head2 plugin
$app->plugin(foo => 'MyApp::Plugin::Foo');
$app->plugin(foo);
$app->plugin(foo => 'MyApp::Plugin::Foo', {bar => 123, baz => 'test'});
$app->plugin(foo => 'MyApp::Plugin::Foo', bar => 123, baz => 'test');
$app->plugin(foo, undef, {bar => 123, baz => 'test'});
Load a plugin by name or pair - name and class
=head2 pwd
my $pwd = $app->pwd;
This method returns current/working directory
=head2 register_handler
use parent qw/Acme::Crux/;
__PACKAGE__->register_handler(
handler => "foo",
aliases => "one, two",
description => "Foo handler",
params => {
param1 => "test",
param2 => 123,
},
code => sub {
### CODE:
my $self = shift; # App
my $meta = shift; # Meta data
my @args = @_; # Arguments
print Acrux::Util::dumper({
meta => $meta,
args => \@args,
});
return 1;
});
Method for register new handler
Example output while running:
$app->run('one', abc => 123, def => 456); # returns 1
{
"args" => ["abc", 123, "def", 456],
"meta" => {
"aliases" => ["one", "two"],
"description" => "Foo handler",
"name" => "foo",
"params" => {
"param1" => "test",
"param2" => 123
}
},
"name" => "foo"
}
This method supports the following options:
=over 4
=item aliases, alias
aliases => 'foo bar baz'
aliases => 'foo, bar, baz'
aliases => [qw/foo bar baz/]
alias => 'foo'
Sets aliases list for handler lookup
=item code
code => sub {
my ($self, $meta, @args) = @_;
( run in 0.598 second using v1.01-cache-2.11-cpan-5a3173703d6 )