+our $VERSION;
+BEGIN {
+ $VERSION = '0.03';
+}
+
+my %opts;
+my $cmd;
+
+BEGIN {
+ @ARGV = grep {
+ defined $cmd ? $_
+ : ( /^-([IKV]+)$/ ? do { $opts{$_} = 1 for split //, $1; () }
+ : do { $cmd = $_ unless /^-/; $_ } )
+ } @ARGV;
+ warn "rgit $VERSION\n" if $opts{V};
+ $cmd = ' ' unless defined $cmd;
+}
+
+BEGIN {
+ if (-t && $opts{I}) {
+ if (eval "require Term::ReadKey; 1") {
+ Term::ReadKey->import;
+ *policy = sub {
+ my ($cmd, $conf, $repo, $status, $signal) = @_;
+ return NEXT unless $status;
+ print STDERR 'The command failed for ' . $repo->work . "\n";
+ print STDERR "[a]bort, [i]gnore, [I]gnore all, [r]etry ?";
+ ReadMode(4);
+ my $key = ReadKey(0);
+ ReadMode(1);
+ print STDERR "\n";
+ my %codes = (
+ 'a' => LAST,
+ 'i' => NEXT,
+ 'I' => NEXT | SAVE,
+ 'r' => REDO,
+ );
+ $key = 'a' unless defined $key;
+ my $code = $codes{$key};
+ $code = $codes{a} unless defined $code;
+ return $code;
+ };
+ } else {
+ warn "You have to install Term::ReadKey to use the interactive mode.\n";
+ }
+ }
+ *policy = sub { NEXT } if $opts{K} and not defined *policy{CODE};
+ *policy = sub {
+ my ($cmd, $conf, $repo, $status, $signal) = @_;
+ return NEXT unless $status;
+ return LAST;
+ } unless defined *policy{CODE};
+}