#!/usr/bin/perl -w

=head1 NAME

module-starter - Creates a skeleton module distribution

=cut

use strict;
use Getopt::Long;
use Pod::Usage;

my $class = 'Module::Starter';
my @plugins;
my @modules;
my $distro;
my $dir;
my @builders;
my ($author, $email, $license, $force, $verbose);

GetOptions(
    "class=s"   =>  \$class,
    "plugin=s"  =>  \@plugins,

    "dir=s"     =>  \$dir,
    "distro=s"  =>  \$distro,
    "module=s"  =>  \@modules,
    "builder=s" =>  \@builders,
    eumm =>         sub { push @builders, "ExtUtils::MakeMaker" },
    mb   =>         sub { push @builders, "Module::Build" },

    "author=s"  =>  \$author,
    "email=s"   =>  \$email,
    "license=s" =>  \$license,
    force   =>      \$force,
    verbose =>      \$verbose,
    version =>      sub { print "module-starter v$Module::Starter::VERSION\n"; exit 1; },
    help =>         sub { pod2usage(1); },
) or pod2usage(2);

@builders = ('ExtUtils::MakeMaker') unless @builders;

eval "require $class;";
die "invalid starter class $class: $@" if $@;
$class->import(@plugins);

$class->create_distro(
    dir     => $dir,
    distro  => $distro,
    modules => [@modules],
    builder => [@builders],
    author  => $author,
    email   => $email,
    license => $license,
    force   => $force,
    verbose => $verbose,
);

print "Created starter directories and files\n";


=head1 SYNOPSIS

module-starter [options]

Options:

    --module=module  Module name (required, repeatable)
    --distro=name    Distribution name (optional)
    --dir            Directory name to create new module in (optional)

    --builder=module Build with 'ExtUtils::MakeMaker' or 'Module::Build'
    --eumm           Same as --build=ExtUtils::MakeMaker
    --mb             Same as --build=Module::Build

    --author=name    Author's name (required)
    --email=email    Author's email (required)
    --license=type   License under which the module will be distributed
                     (default is the same license as perl)

    --verbose        Print progress messages while working
    --force          Delete pre-existing files if needed

    --help           Show this message

Example:

    module-starter --module=Foo::Bar,Foo::Bat \
        --author="Andy Lester" --email=andy@petdance.com

=head1 DESCRIPTION

C<module-starter> is a command-line interface to L<Module::Starter>, which it
uses to perform all the work of creating distributions.  An alternate backend
for C<module-starter> can be specified with the C<--class> option.  Plugins to
the standard Module::Starter module can be specified with one or more
C<--plugin> options.

If no directory name is supplied, the distribution name will be used for the
directory.  If no distribution name is supplied, the first listed module name
will be used as the distribution name.

Multiple --builder options may be supplied to produce the files for multiple
builders.

=cut

