#!/usr/local/bin/perl

eval 'exec /usr/local/bin/perl  -S $0 ${1+"$@"}'
  if 0;    # not running under some shell

use strict;
local $^W = 1;

use Getopt::Std;
use ExtUtils::ModuleMaker 0.34;
use ExtUtils::ModuleMaker::Interactive qw| run_interactive |;

use vars qw (%opts $VERSION);

$VERSION = 0.36;

getopts( "bdhqCIPVcn:a:v:l:u:p:o:w:e:", \%opts );
die Usage() if ( $opts{h} );

my %AUTHOR = (
    NAME         => ($opts{u} ? $opts{u} : 'A. U. Thor'),
    CPANID       => ($opts{p} ? $opts{p} : 'AUTHOR'),
    ORGANIZATION => ($opts{o} ? $opts{o} : 'XYZ Corp.'),
    WEBSITE      => ($opts{w} ? $opts{w} : 'http://a.galaxy.far.far.away/modules'),
    EMAIL        => ($opts{e} ? $opts{e} : 'a.u.thor@a.galaxy.far.far.away'),
);

my $MOD   = ExtUtils::ModuleMaker->new(
    COMPACT          => ( ( $opts{c} ) ? 1 : 0 ),
    VERBOSE          => ( ( $opts{V} ) ? 1 : 0 ),
    CHANGES_IN_POD   => ( ( $opts{C} ) ? 1 : 0 ),
    NEED_POD         => ( ( $opts{P} ) ? 0 : 1 ),
    NEED_NEW_METHOD  => ( ( $opts{q} ) ? 0 : 1 ),
    INTERACTIVE      => ( ( $opts{I} ) ? 0 : 1 ),
    ( ( $opts{n} ) ? ( NAME         => $opts{n} ) : () ),
    ( ( $opts{a} ) ? ( ABSTRACT     => $opts{a} ) : () ),
    ( ( $opts{b} ) ? ( BUILD_SYSTEM => $opts{b} ) : () ),
    ( ( $opts{v} ) ? ( VERSION      => $opts{v} ) : () ),
    ( ( $opts{l} ) ? ( LICENSE      => $opts{l} ) : () ),
    AUTHOR => \%AUTHOR,
    USAGE_MESSAGE => Usage(),
);

# $MOD->partial_dump(qw| LicenseParts USAGE_MESSAGE |);

if ( $MOD->{INTERACTIVE} ) {
    $MOD = run_interactive($MOD);
    build_and_close($MOD);
}
else {
    build_and_close($MOD);
}

########## END STATEMENTS ##########

########## BEGIN SUBROUTINES ##########

sub build_and_close {
    my $MOD = shift;
    $MOD->complete_build();
    print "\n-------------------\n\nModule files generated.  Good bye.\n\n";
}
	
sub Usage {
    my $message = <<ENDOFUSAGE;
modulemaker [-CIPVch] [-v version] [-n module_name] [-a abstract]
        [-u author_name] [-p author_CPAN_ID] [-o organization]
        [-w author_website] [-e author_e-mail]
        [-l license_name] [-b build_system]

Currently Supported Features
    -a   Specify (in quotes) an abstract for this extension
    -b   Specify a build system for this extension
    -c   Flag for compact base directory name
    -C   Omit creating the Changes file, add HISTORY heading to stub POD
    -e   Specify author's e-mail address
    -h   Display this help message
    -I   Disable INTERACTIVE mode, the command line arguments better be complete
    -l   Specify a license for this extension
    -n   Specify a name to use for the extension (required)
    -o   Specify (in quotes) author's organization
    -p   Specify author's CPAN ID
    -P   Omit the stub POD section
    -u   Specify (in quotes) author's name
    -v   Specify a version number for this extension
    -V   Flag for verbose messages during module creation
    -w   Specify author's web site

modulemaker version: $VERSION
ExtUtils::ModuleMaker version: $ExtUtils::ModuleMaker::VERSION
ENDOFUSAGE

    return ($message);
}

#'

################### DOCUMENTATION ################### 

=head1 NAME

modulemaker - interactive interface to ExtUtils::ModuleMaker

=head1 VERSION

This document references version 0.36 of modulemaker, released
to CPAN on July 18, 2005.

=head1 USAGE

=head2 Easy

At the command-prompt, simply call:

    % modulemaker

... and answer each question.

=head2 Not So Easy, But More Geeky

At the command-prompt, call C<modulemaker> with as many options as you can type correctly:

    modulemaker [-CIPVch] [-v version] [-n module_name] [-a abstract]
        [-u author_name] [-p author_CPAN_ID] [-o organization]
        [-w author_website] [-e author_e-mail]
        [-l license_name] [-b build_system]

Currently Supported Features

=over 4

=item * -a

Specify (in quotes) an abstract for this extension

=item * -b

Specify a build system for this extension

=item * -c

Flag for compact base directory name

=item * -C

Omit creating the Changes file, add HISTORY heading to stub POD

=item * -e

Specify author's e-mail address

=item * -h

Display this help message

=item * -I

Disable INTERACTIVE mode, the command line arguments better be complete

=item * -l

Specify a license for this extension

=item * -n

Specify a name to use for the extension (required)

=item * -o

Specify (in quotes) author's organization

=item * -p

Specify author's CPAN ID

=item * -P

Omit the stub POD section

=item * -q

Do not include a constructor (C<new()>) in the F<*.pm> file.

=item * -u

Specify (in quotes) author's name

=item * -v

Specify a version number for this extension

=item * -V

Flag for verbose messages during module creation

=item * -w

Specify author's web site

=back

=head1 AUTHOR

ExtUtils::ModuleMaker was originally written in 2001-02 by R. Geoffrey Avery
(modulemaker [at] PlatypiVentures [dot] com).  Since version 0.33 (July
2005) it has been maintained by James E. Keenan (jkeenan [at] cpan [dot]
org).

=head1 COPYRIGHT

Copyright (c) 2001-2002 R. Geoffrey Avery.
Revisions from v0.33 forward (c) 2005 James E. Keenan.  All rights reserved.
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the
LICENSE file included with this module.

=head1 SEE ALSO

F<ExtUtils::ModuleMaker>, F<perlnewmod>, F<h2xs>, F<ExtUtils::MakeMaker>.

=cut

