http://www.perlmonks.org?node_id=183829


in reply to Re: ExtUtils::ModuleMaker
in thread ExtUtils::ModuleMaker

Here's my revamp of simonflk's utility rolling in D&P's compact stuff:

STANDARD COMPACT USAGE:

$> newmodule -name Foo::Bar -version 0.01 -compact 1
$> newmodule -n Foo::Bar -v 0.01 -c 1
COMPACT USAGE WITH VERSION # IN FOLDER NAME:
$> newmodule -name Foo::Bar -version 0.01 -compact 2
$> newmodule -n Foo::Bar -v 0.01 -c 2
$> newmodule -n Foo::Bar -v 0.01 (My Default Setting)
DEFAULT FOLDER NAMING USAGE:
$> newmodule -name Foo::Bar -version 0.01 -compact 0
$> newmodule -n Foo::Bar -v 0.01 -c 0
#!/usr/bin/perl use strict; use warnings; use Getopt::Long; use ExtUtils::ModuleMaker 0.204; my %author = ( NAME => 'Christopher Baker', EMAIL => 'ignatz@ignatzmouse.com', # CPANID => 'IGNATZ', Someday *SIGH* WEBSITE => 'http://www.ignatzmouse.com' ); # Set some defaults my $license = 'perl'; my $version = '0.01'; my $module_name = ''; my $compact = 2; my $extra_modules = ''; my @extra_modules = (); GetOptions ( 'name=s' => \$module_name, 'version:f' => \$version, 'license:s' => \$license, 'extra:s' => \$extra_modules, 'compact:i' => \$compact ); Usage() unless $module_name; ###################################################################### +######### # Now make the module ###################################################################### +######### push @extra_modules, {NAME => $_, ABSTRACT => $_} for split /,/, $extra_modules; Generate_Module_Files ( NAME => $module_name, ABSTRACT => $module_name, AUTHOR => \%author, VERSION => $version, LICENSE => $license, compact => $compact, # Module uses wrong option case, not C +OMPACT EXTRA_MODULES => \@extra_modules ); if ($compact == 2) { my $dir_name = $module_name; $dir_name =~ s/::/-/g; print STDERR "renaming '$dir_name' to '$dir_name-$version'\n"; rename $dir_name, "$dir_name-$version" or warn "Could not rename '$dir_name' to '$dir_name-$version': + $!"; } sub Usage { my ($prog) = $0 =~ /\/([^\/]+)$/; print <<HELP; $prog - Simple Module Maker Usage: $prog <-name ModuleName> [-version=?] [-extra=?,?] [-license=?] + [-compact=?] Eg: $prog -name My::Module $prog -name My::Module -version 0.11 -extra My::Utils,My::Extra -license perl HELP }
()-()
 \"/
  `                                                     

Replies are listed 'Best First'.
Re3: ExtUtils::ModuleMaker
by dragonchild (Archbishop) on Oct 10, 2003 at 19:30 UTC
    If you execute this script in the same directory as it and you don't pass any parameters, your Usage() doesn't construct $prog correctly.
    my ($prog) = $0 =~ /\/([^\/]+)$/; ---- Change to: use File::Basename; ... my ($prog) = basename($0);

    ------
    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Re:^3 ExtUtils::ModuleMaker
by mpd (Monk) on Aug 18, 2003 at 03:11 UTC
    compact        => $compact, # Module uses wrong option case, not COMPACT

    Not anymore, at least as of version 0.32. Couldn't find anything in the changelog regarding the switch, but it's 'correctly' capitalized now. Just wanted to give a heads up.