Acrux
view release on metacpan or search on metacpan
eg/acrux_test.pl view on Meta::CPAN
#!/usr/bin/perl -w
use strict;
# perl -Ilib eg/acrux_test.pl test 1 2 3
package MyApp;
use parent 'Acme::Crux';
use Acrux::Util qw/dumper color/;
our $VERSION = '1.00';
sub startup {
my $self = shift;
print sprintf(color(green => "Start application %s"), $self->project), "\n" ;
# Set plugin 'Test'
$self->plugin(Test => 'MyTestPlugin'); # $self->test;
return $self;
}
DESTROY {
my $el = sprintf("%+.*f sec", 4, $_[0]->elapsed);
print sprintf(color(green => "Finish application %s ($el)"), $_[0]->project), "\n" ;
}
__PACKAGE__->register_handler; # default
__PACKAGE__->register_handler(
handler => "test",
description => "Test handler",
code => sub {
### CODE:
my ($self, $meta, @args) = @_;
$self->test; # Call created method
#print dumper(
# "App:" => $self,
# "Meta:" => $meta,
# "Args:" => \@args,
# );
$self->log->debug(sprintf('Config value "/deep/foo/bar/test": >%s<',
$self->config->get("/deep/foo/bar/test")));
# Test log
#$self->log->trace('Whatever');
#$self->log->debug('You screwed up, but that is ok');
#$self->log->info('You are bad, but you prolly know already');
#$self->log->notice('Normal, but significant, condition...');
#$self->log->warn('Dont do that Dave...');
#$self->log->error('You really screwed up this time');
#$self->log->fatal('Its over...');
#$self->log->crit('Its over...');
#$self->log->alert('Action must be taken immediately');
#$self->log->emerg('System is unusable');
return 1;
});
1;
package main;
use Getopt::Long;
use IO::Handle;
use Acrux::Util qw/dumper color/;
# Get options from command line
Getopt::Long::Configure("bundling");
GetOptions(my $options = {},
"verbose|v", # Verbose mode
( run in 1.737 second using v1.01-cache-2.11-cpan-40ba7b3775d )