#!/usr/bin/env perl6
use v6;
use App::Mi6;

my %*SUB-MAIN-OPTS = :named-anywhere;
my $app = App::Mi6.new;

multi MAIN("version") {
    say $app.^ver;
}
multi MAIN("new", $module) {
    $app.cmd("new", $module);
}
multi MAIN("build") {
    $app.cmd("build");
}
multi MAIN("test", *@file, Bool :v(:$verbose), Int :j(:$jobs)) {
    $app.cmd("test", @file, :$verbose, :$jobs);
}
multi MAIN("release", Bool :$keep) {
    $app.cmd("release", :$keep);
}
multi MAIN("dist") {
    $app.cmd("dist");
}
multi MAIN("upload") {
    die "`mi6 upload` is removed, please execute `mi6 release` instead.\n";
}
multi MAIN("help") { usage }
multi MAIN(:h(:$help)!) { usage}
sub usage() {
    require Pod::To::Text;
    ::("Pod::To::Text").render($=pod).say;
}

=begin pod

=head1 USAGE

  > mi6 new Foo::Bar # create Foo-Bar distribution
  > mi6 build        # build the distribution, and re-generate README.md/META6.json
  > mi6 test         # run tests
  > mi6 release      # release your distribution tarball to CPAN

  Examples:
  > mi6 --verbose test    # run tests with verbose mode (alias: -v)
  > mi6 --jobs=N  test    # run N test jobs in parallel (alias: -j)
  > mi6 test t/02-test.t  # run specific test
  > mi6 release

=end pod
