| Module-New documentation | Contained in the Module-New distribution. |
Module::New::Recipe
package Your::Module::New::Recipe::Something;
use strict;
use warnings;
use Module::New::Recipe;
use Module::New::Command::Basic;
available_options ();
flow {
guess_root;
loop {
do_something;
};
};
1;
This is a base class which provides basic DSLish commands to define recipes. See also Module::New::Command::Basic.
defines command line option specifications which will be passed to Getopt::Long::Parser.
defines a recipe/command flow. All the commands in the flow would take $self and all the arguments passed through the command line.
defines an internal loop. All the commands in the loop would take $self and an argument per iteration.
Kenichi Ishigaki, <ishigaki@cpan.org>
Copyright (C) 2007-2009 by Kenichi Ishigaki.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Module-New documentation | Contained in the Module-New distribution. |
package Module::New::Recipe; use strict; use warnings; use Carp; use Module::New::Meta; use Module::New::Queue; my @options; functions { flow => sub (&) { my $flow = shift; Module::New::Queue->register(sub { my ($self, @args) = @_; Module::New::Queue->localize(sub { $flow->(); Module::New::Queue->consume( $self, @args ); }) }) }, loop => sub (&) { my $loop = shift; Module::New::Queue->register(sub { my ($self, @args) = @_; Module::New::Queue->localize(sub { $loop->(); foreach my $arg ( @args ) { Module::New::Queue->consume( $self, $arg ); } }); }); }, available_options => sub (@) { @options = @_ }, }; methods { options => sub { @options }, run => sub { my ($self, @args) = @_; Module::New::Queue->consume( $self, @args ); } }; 1; __END__