#!/usr/bin/env perl

=head1 NAME

appcmd-starter - creates a skeleton App::Cmd distribution

=cut

use strict;
use warnings;
use Getopt::Long qw/:config pass_through/;

use Module::Starter qw(
  Module::Starter::Plugin::App::Cmd
);

use Class::Monkey qw/Module::Starter::App/;

around '_process_command_line' => sub {
    my ($method, $self, %config) = @_;
    
    if (@ARGV) {
        GetOptions(
            'commands=s' => \$config{commands},
            'script=s'   => \$config{script},
        );
    }

    $self->$method(%config);
}, 'Module::Starter::App';

Module::Starter::App->run;

=head1 SYNOPSIS

appcmd-starter [options]

Options:

    --module=module     Module name (required, repeatable)
    --distro=name       Distribution name (optional)
    --dir=dirname       Directory name to create new module in (optional)
    
    --script=name       Name of the command-line application to create (required)
    --commands=foo,bar  Comma separated list of commands to create (required)

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

    --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

Available Licenses:
    perl, artistic, artistic2, mit, mozilla, mozilla2, bsd, freebsd, cc0,
    gpl, lgpl, gpl3, lgpl3, agpl3, apache, qpl

Example:

    appcmd-starter --module=Foo::Bar --script=foo --commands=bar,baz \
        --author="JJ Allen" --email=jj@jonallen.info

=head1 DESCRIPTION

C<appcmd-starter> is a plugin for C<module-starter> to create App::Cmd
distributions, i.e. a skeleton module for an App::Cmd application with stub
modules and methods for all commands specified by the C<--cmd> option.

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.

=head1 CONFIGURATION

module-starter will look for a configuration file before reading its command
line parameters.  The default location is C<$HOME/.module-starter/config> but
if the MODULE_STARTER_DIR environment variable is set, module-starter will look
for C<config> in that directory.

The configuration file is just a list of names and values, separated by colons.
Values that take lists are just space separated.  A sample configuration file
might read:

 author: Ricardo SIGNES
 email:  rjbs@cpan.org
 plugins: Module::Starter::Simple Module::Starter::Plugin::XYZ
 xyz_option: red green blue

This format may become more elaborate in the future, but a file of this type
should remain valid.

=cut

