Crane - Helpers for development in Perl
use Crane; ... use Crane ( 'name' => 'example' );
Helpers for development in Perl. Includes the most modern technics and rules.
Also imports modules as "Crane::Base" in Crane::Base;
You can specify these options when using module:
Script name, used when run as daemon.
If defined, run as daemon by default. Use --no-daemon command line option to cancel this behavior.
Array (reference) to list of base modules.
Array (reference) of options which will be added to the head of default options list.
Hash (reference) with user defined default settings.
Custom namespace. Please, look at examples below.
These options are available by default. You can define your custom options if specify it in the import options.
Runs as daemon.
Path to configuration file.
Path to PID file.
Path to messages log file.
Path to errors log file.
Debug output.
Verbose output.
Shows version information and exits.
Shows help and exits.
In case of running as daemon will return 1 if process is already running.
Where %d is a PID.
You tried to run application as daemon while another copy is running.
use Crane; ... use Crane ( 'base' => qw( Mojolicious::Controller ) );
use Crane ( 'name' => 'example' );
use Crane ( 'options' => [ [ 'from|F=s', 'Start of the interval.', { 'required' => 1 } ], [ 'to|F=s', 'End of the interval.', { 'required' => 1 } ], ] );
As a result you have these two options, a separator and default options.
package My; use Crane ( 'namespace' => 'My', 'config' => { 'my' => { 'autorun' => 1, 'hosts' => [ '127.0.0.1', '127.0.0.2', ], }, }, ); 1; ... use My; use My::Config; use My::Logger; log_info(config->{'log'});
package My; use Crane::Base; use Crane::Options qw( :opts ); require Crane; sub import { my ( $package, $name ) = @_; Crane->import( 'namespace' => 'My', 'name' => $name, 'options' => [ [ 'run!', 'Do action at startup.' ], $OPT_SEPARATOR, [ 'host=s@', 'Host name(s).' ], ], 'config' => { 'my' => { 'autorun' => 1, 'hosts' => [ '127.0.0.1', '127.0.0.2', ], }, }, ); return; } 1; ... use My 'my_script'; sub main { ... return 0; } exit main();
See Crane::Base.
Configuration files. See Crane::Config.
Log files. See Crane::Logger.
Script's PID file.
Please report any bugs or feature requests to https://rt.cpan.org/Public/Bug/Report.html?Queue=Crane or to https://github.com/temoon/crane/issues.
Tema Novikov, <novikov.tema@gmail.com>
Copyright (C) 2013-2014 Tema Novikov.
This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license in the file LICENSE.
RT Cpan
https://rt.cpan.org/Public/Dist/Display.html?Name=Crane
Github
https://github.com/temoon/crane
To install Crane, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Crane
CPAN shell
perl -MCPAN -e shell install Crane
For more information on module installation, please visit the detailed CPAN module installation guide.