App-Multigit
view release on metacpan or search on metacpan
#!perl
use strict;
use warnings;
use 5.014;
use Future;
use Path::Class;
use File::Which qw(which);
use Cwd qw(getcwd);
use App::Multigit;
use Getopt::Long qw(:config gnu_getopt require_order);
use Pod::Usage;
use Try::Tiny;
sub usage;
{
my $qs = 0;
GetOptions(
help => \&usage,
'quiet|q' => sub {
# Can't use + for this because -v needs to counteract it.
$qs++;
},
'verbose|v' => sub {
$qs--;
},
'concurrent|c=i' => \$ENV{MG_CONCURRENT_PROCESSES},
'skip-readonly' => \$ENV{MG_SKIP_READONLY},
'output-only|o' => \$ENV{MG_OUTPUT_ONLY},
);
if ($qs > 0) {
$ENV{MG_REPORT_ON_NO_OUTPUT} = 0;
}
if ($qs > 1) {
$ENV{MG_IGNORE_STDERR} = 1;
}
}
my $cmd = shift or usage 1;
if ($cmd eq 'help') {
# mg help is just usage
$cmd = shift or usage;
@ARGV = '--help';
}
else {
# mg-init may be run in a new mg, or in an existing one.
my @workdir = try { '--workdir', App::Multigit::mg_parent } catch {};
unshift @ARGV, @workdir;
}
my $mg_cmd = which("mg-$cmd") // die "$cmd is not an mg command.\n";
exec $mg_cmd, @ARGV
or die "Failed to exec $mg_cmd: $!";
sub usage {
my $exitcode = shift // 0;
pod2usage({ -exitcode => $exitcode, -verbose => 2 });
}
=head1 SYNOPSIS
mg [options] command [command-options]
mg help [command]
Runs mg-$command, which may or may not run something in each repository.
C<options> control the environment of mg itself; C<command-options> control the
( run in 1.190 second using v1.01-cache-2.11-cpan-39bf76dae61 )