X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Frgit.git;a=blobdiff_plain;f=bin%2Frgit;h=83bd219a1c0a35558b8fd6a926d0fcbaa6dcdbf1;hp=326d56edf3f4872485549e7702adc1bfc6ee5446;hb=00f4d1f6016748f8b4623d8ff32546069f763a95;hpb=7a8f16273acc8e184a0bf1c74cb7812591c31e67 diff --git a/bin/rgit b/bin/rgit index 326d56e..83bd219 100755 --- a/bin/rgit +++ b/bin/rgit @@ -8,7 +8,7 @@ use Config qw/%Config/; 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; @@ -22,10 +22,9 @@ my $cmd; 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; } @@ -68,13 +67,18 @@ croak "Couldn't find any valid git executable" unless defined $git; 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) = @_; @@ -95,28 +99,28 @@ sub policy_interactive { ); 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]; } } @@ -134,7 +138,7 @@ Version 0.04 =head1 SYNOPSIS - rgit [-K|-V|-I] [GIT_OPTIONS] COMMAND [COMMAND_ARGS] + rgit [-K|-I|-D|-V] [GIT_OPTIONS] COMMAND [COMMAND_ARGS] =head1 DESCRIPTION @@ -211,6 +215,12 @@ This lets you choose interactively what to do when one of the commands returns a =item * +C<-D> + +Outputs diagnostics. + +=item * + C<-V> Outputs the version.