-
-
08 Mar 2019 03:07:13 UTC
- Distribution: Beam-Runner
- Module version: 0.016
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (6)
- Testers (536 / 16 / 4)
- Kwalitee
Bus factor: 1- 95.11% Coverage
- License: perl_5
- Perl: v5.10.0
- Activity
24 month- Tools
- Download (35.79KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
NAME
Beam::Runnable - Role for runnable objects
VERSION
version 0.016
SYNOPSIS
package My::Runnable; use Moo; with 'Beam::Runnable'; sub run { ... }
DESCRIPTION
This role declares your object as runnable by the
beam run
command. Runnable objects will be listed by thebeam list
command, and their documentation displayed by thebeam help
command.The
run
methodThe
run
method is the main function of your object. See below for its arguments and return value.The
run
method should be as small as possible, ideally only parsing command-line arguments and delegating to other objects to do the real work. Though your runnable object can be used in other code, the API of therun
method is a terrible way to do that, and it is better to keep your business logic and other important code in another class.Documentation
The
beam help
command will display the documentation of your module: theNAME
(abstract),SYNOPSIS
,DESCRIPTION
,ARGUMENTS
,OPTIONS
, andSEE ALSO
sections. This is the same as what Pod::Usage produces by default.The
beam list
command, when listing runnable objects, will display either thesummary
attribute or theNAME
POD section (abstract) next to the service name.Additional Roles
Additional roles can add common functionality to your runnable script. Some of these are included in the
Beam::Runner
distribution:- Beam::Runnable::Timeout::Alarm
-
This role will add a timeout using Perl's built-in alarm() function. Once the timeout is reached, the program will print a warning and exit with an error code.
ATTRIBUTES
summary
A summary of the task to be run. This will be displayed by the
beam list
command in the list.METHODS
run
my $exit_code = $obj->run( @argv );
Execute the runnable object with the given arguments and returning the exit status.
@argv
is passed-in from the command line and may contain options (which you can parse using Getopt::Long's GetOptionsFromArray function.SEE ALSO
AUTHOR
Doug Bell <preaction@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install Beam::Runner, copy and paste the appropriate command in to your terminal.
cpanm Beam::Runner
perl -MCPAN -e shell install Beam::Runner
For more information on module installation, please visit the detailed CPAN module installation guide.