| Module-New documentation | Contained in the Module-New distribution. |
Module::New - creates module/distribution skeleton and more
From a command line > module_new dist Dist-Name > cd Dist-Name/trunk > module_new file Dist::Name::Plugin > module_new file t/dist_test.t --edit > module_new manifest --force
This is yet another module starter. You can use this not only when you create a new distribution but also when you add a new module or test or plain text to the distribution. You may want to edit a new file after creation. You may want to update MANIFEST. This'll do.
Generally, 'module_new' command takes one recipe (sub-command) name, arguments for the recipe and global or local options if any. See appropriate PODs for details.
specifies global command line options, which all the recipes (sub-commands) should have.
specifies a default recipe which would be executed when you don't give any recipe ('help' by default).
parses command line options and dispatches to the requested recipe.
sets up a context object.
sets up a context object if necessary, and returns the object.
Kenichi Ishigaki, <ishigaki at 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; use strict; use warnings; use Carp; use Module::New::Loader; our $VERSION = '0.05'; my $CONTEXT; sub options {qw( help|h|? author=s email=s force|f grace subdir|in=s )} sub default { 'help' } sub setup { my ($class, @bases) = @_; my $loader = Module::New::Loader->new( @bases ); $CONTEXT = $loader->load( 'Context', undef, @bases ); $CONTEXT->config->get_options( $class->options ); $CONTEXT; } sub context { $CONTEXT ? $CONTEXT : shift->setup } sub dispatch { my ($class, @bases) = @_; $class->setup(@bases); my $name = shift @ARGV || $class->default; unshift @ARGV, $name if $CONTEXT->config('help'); my $recipe = $CONTEXT->loader->load_class( Recipe => $name ); $CONTEXT->config->get_options( $recipe->options ); croak "author is required" unless $CONTEXT->config('author'); croak "email is required" unless $CONTEXT->config('email'); $recipe->run( @ARGV ); } 1; __END__