#! perl

use strict;
use warnings;
use App::ModuleBuildTiny;

our $VERSION = '0.038';

modulebuildtiny(@ARGV);

__END__

=head1 NAME

mbtiny - A standalone authoring script for Module::Build::Tiny

=head1 SYNOPSIS

 mbtiny listdeps | cpanm
 mbtiny test --release
 mytiny regenerate
 mbtiny upload

=head1 DESCRIPTION

C<mbtiny> is a tool to help assemble your CPAN distributions. It's a minimalist tool that tries to come with as few surprises as possible, and thus provide a gentle learning curve for its users.

=head1 SUBCOMMANDS

=head2 regenerate [--bump] [--version=<version] [--verbose] [--dry-run] [--scan] <files>...

This regenerates the given files. If no files are given, it defaults to all six files it can regenerate. You usually want to do this when bumping the version of a module. It has the following options:

=over 4

=item * bump

Bump the version of the distribution before regenerating. The default for this can be set in the configuration.

=item * version = <new-version>

Set the version of the distribution before regenerating.

=item * scan

Scan for dependencies to include in the metafiles. The default for this can be set in the configuration.

=item * trial

Make the new version a trial version.

=item * commit

Create a git commit for the version bump. The default for this can be set in the configuration.

=item * verbose

This will make regeneration more verbose.

=item * dry-run

This will cause it to not write anything to disk, this is only ever useful when combined with the verbose option.

=back

It generates the following files:

=over 4

=item * Build.PL

This contain the code needed to build the dist using L<Module::Build::Tiny|Module::Build::Tiny>.

=item * MANIFEST

This contains the list of files in this distribution, and optionally descriptions.

=item * META.json

The file containing most meta information about this distributions. Useful for both presenting information to the user as for installing the distribution.

=item * META.yml

This is the legacy meta file. This is mainly useful for bootstrapping on CPAN clients too old to support META.json but recent enough to support configure_requires.

=item * README

A file containing a description of the project, based on the documentation of the main module.

=item * LICENSE

This contains the license of the distribution.

=back

=head2 upload [--silent] [--config=<config_file>] [--tag] [--push]

This assembles a tarball and uploads it to CPAN.

Using a L<Config::Identity|Config::Identity> compatible F<.pause> file in your home directory is recommended, but if it's absent or incomplete your credentials will be asked on the console.

=over 4

=item * tag

Tag the current release with the current version. The default for this can be set in the configuration.

=item * push

Push the current commit, and tag it C<--tag> is also specified. The default for this can be set in the configuration.

=item * silent

This will enable silent mode

=item * config=<config-file>

The location of your pause credentials

=back

=head2 test [--no-author] [--release]

This runs all of the tests of a distribution. It takes two negatable options:

=over 4

=item * release

Run release tests. Defaults to false.

=item * author

Run author tests. Defaults to true.

=back

=head2 scan [--omit-core=<version>] [--omit=<module>]

This will scan the C<lib/>, C<script/> and C<t/> directories for dependencies and writes them to C<prereqs.json>. It accepts the following option:

=over 4

=item * omit_core = version

This allows you to set a minimum perl version (e.g. C<5.008001> or C<v5.8.1>) whose core-provided dependencies will not be explicitly included.

=item * omit = module

This will omit a specific from the dependencies, it can be specified multiple times.

=back

=head2 mint [--<option>=<value>]...  <distribution>

This creates a new distribution. It takes one mandatory positional argument, the name of the new distribution, and up to six optional named arguments

=over 4

=item * abstract

The abstract of this new distribution. It defaults to an empty string.

=item * author

The name of the author of this distribution. The default value is set in the configuration file.

=item * dirname

The directory name for the new distribution. It defaults to the distribution name.

=item * email

The email address of the author. The default value is set in the configuration file.

=item * license

The license of the new distribution. It default is set in the configuration file, this is usually C<Perl_5>.

=item * version

The initial version of the new distribution. This defaults to C<0.001>.

=item * init-git

Initialize a git repository on minting.

=back

=head2 setup <type>

This creates or update your configuration file (at F<~/.mbtiny/config>). It takes one optional position argument that can take any of the following values:

=over 4

=item * update

This asks you about all configuration items that are currently empty. This is the default.

=item * all

This asks you about all configuration items, even if they currently have a value.

=item * list

This lists your current configuration.

=item * reset

This removes the current configuration file.

=back

=head2 listdeps [--versions] [--json] [--missing] [--omit-core=<version>]

List all dependencies of this distribution. By default it prints a list of modules. If the C<json> option option is given, it's printed as JSON instead.

=over 4

=item * versions

This will cause it to print out the required versions along with the modules.

=item * json

This will cause it to output the dependencies in JSON format, instead of a list format

=item * missing

This will cause it to list only modules whose requirement isn't met.

=item * author

This will cause the list to include development-time dependencies, such as C<App::ModuleBuildTiny> itself.

=item * omit-core=<perl-version>

This will cause the list to exclude any prerequisites that are provided by that specific perl version.

=back

=head2 run [--no-build] <command>

Run the specified command in an assembled distribution. It takes one boolean argument:

=over 4

=item * no-build

This will cause mbtiny not to build the distribution (run C<Build.PL> and C<Build>) before running the command.

=back

=head2 shell [--build]

Runs the C<$SHELL>, this is equivalent to C<mbtiny run --no-build $SHELL>. It takes one argument.

=over 4

=item * build

This will cause mbtiny to build the distribution before running the shell.

=back

=head2 dist

This creates a distribution tarball.

=head2 distdir

This creates a directory containing all of the files of the distribution.

=head1 INPUTS

The metadata for the distribution is gathered from various sources.

=over 4

=item *

The distribution name is taken from the local directory name.

=item *

The version, abstract and author are taken from the main module of the distribution.

=item *

The license is extracted from the POD, unless a metamerge file overrides this

=item *

Prerequisites are mostly taken from C<prereqs.json>, C<prereqs.yml> and (discouraged) L<cpanfile>, except when injected explicitly (e.g. a configure dependency on L<Module::Build::Tiny|Module::Build::Tiny>).

 # prereqs.yml
 runtime:
   requires:
     perl: '5.012'
     Path::Tiny: 0
   recommends:
     Term::ReadLine::Gnu: 0
 test:
   requires:
     Test::More: '0.88'

=item *

A C<metamerge.json> or C<metamerge.yml> file can be used to merge any additional meta information you want (including dependencies). It is assumed to be in L<meta-spec 2 format|https://metacpan.org/pod/CPAN::Meta::Spec> unless otherwise specified.

 # metamerge.yml
 resources:
   bugtracker:
     web: https://github.com/leont/App-ModuleBuildTiny/issues
   homepage: http://example.org/
   x_IRC: irc://irc.perl.org/#toolchain

=back
