use Cwd qw/cwd/;
use File::Spec::Functions qw/catfile path/;
-use App::Rgit::Utils qw/:codes/;
+use App::Rgit::Utils qw/:codes :levels/;
use App::Rgit;
our $VERSION;
BEGIN {
@ARGV = grep {
defined $cmd ? $_
- : ( /^-([IKV]+)$/ ? do { $opts{$_} = 1 for split //, $1; () }
- : do { $cmd = $_ unless /^-/; $_ } )
+ : ( /^-([DIKV]+)$/ ? do { $opts{$_} = 1 for split //, $1; () }
+ : do { $cmd = $_ unless /^-/; $_ } )
} @ARGV;
- warn "rgit $VERSION\n" if $opts{V};
$cmd = ' ' unless defined $cmd;
}
my $root = $ENV{GIT_DIR};
$root = cwd unless defined $root;
-exit App::Rgit->new(
+my $ar = App::Rgit->new(
git => $git,
root => $root,
cmd => $cmd,
args => \@ARGV,
policy => \&policy,
-)->run;
+ debug => $opts{D} ? INFO : WARN,
+);
+
+print STDOUT "rgit $VERSION\n" if $opts{V};
+
+exit $ar->run;
sub policy_default {
my ($cmd, $conf, $repo, $status, $signal) = @_;
);
my $int = { GetControlChars() }->{INTERRUPT};
while (1) {
- print STDERR "[a]bort, [i]gnore, [I]gnore all, [r]etry, open [s]hell ?";
+ $conf->warn("[a]bort, [i]gnore, [I]gnore all, [r]etry, open [s]hell ?");
ReadMode(4);
my $key = ReadKey(0);
ReadMode(1);
print STDERR "\n";
next unless defined $key;
if ($key eq $int) {
- print STDERR "Interrupted, aborting\n";
+ $conf->warn("Interrupted, aborting\n");
return LAST;
} elsif ($key eq 's') {
if (defined $shell) {
- print STDERR 'Opening shell in ', $repo->work, "\n";
+ $conf->info('Opening shell in ', $repo->work, "\n");
my $cwd = cwd;
$repo->chdir;
system { $shell } $shell;
chroot $cwd;
} else {
- print STDERR "Couldn't find any shell\n";
+ $conf->err("Couldn't find any shell\n");
}
} elsif (exists $codes{$key}) {
my $code = $codes{$key};
- print STDERR 'Okay, ', $code->[1], "\n";
+ $conf->info('Okay, ', $code->[1], "\n");
return $code->[0];
}
}
=head1 SYNOPSIS
- rgit [-K|-V|-I] [GIT_OPTIONS] COMMAND [COMMAND_ARGS]
+ rgit [-K|-I|-D|-V] [GIT_OPTIONS] COMMAND [COMMAND_ARGS]
=head1 DESCRIPTION
=item *
+C<-D>
+
+Outputs diagnostics.
+
+=item *
+
C<-V>
Outputs the version.