diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2019-12-19 16:53:37 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2019-12-19 16:53:37 -0700 |
commit | 082bf8f988f28657eb4c6e305db4196d1d3ed6e2 (patch) | |
tree | 475fec082dcad345f31a699af4275cc4c72d9e18 /lib | |
parent | 63508b17ad773418e4b63da2f46e88ba30f05f5f (diff) | |
download | dotfiles-082bf8f988f28657eb4c6e305db4196d1d3ed6e2.tar.gz |
implement 'b' and 'd' options in annex-review-unused
Diffstat (limited to 'lib')
-rw-r--r-- | lib/perl5/Local/MrRepo/Repo/Git/Annex.pm | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/perl5/Local/MrRepo/Repo/Git/Annex.pm b/lib/perl5/Local/MrRepo/Repo/Git/Annex.pm index da96958e..e58f5428 100644 --- a/lib/perl5/Local/MrRepo/Repo/Git/Annex.pm +++ b/lib/perl5/Local/MrRepo/Repo/Git/Annex.pm @@ -111,7 +111,9 @@ sub review_unused { $unused_file->{key}); } - foreach my $unused_file (@unused_files) { + my $i = 0; + UNUSED: while ($i < @unused_files) { + my $unused_file = $unused_files[$i]; system('clear', '-x') if $opts{interactive}; say_bold("unused file #" . $unused_file->{number} . ":"); @@ -156,12 +158,9 @@ sub review_unused { ReadMode 4; while (defined ReadKey(-1)) { } - # would be good if user could say 'b' to go back - # to the previous entry. would probably have to - # implement this by replacing the foreach loop - # with a while loop with a manually maintained - # array index into @unused_files. - print "Drop this unused file? (y/n/o) "; + $i > 0 + ? print "Drop this unused file? (y/n/o/d/b) " + : print "Drop this unused file? (y/n/o) "; # Term::ReadKey docs recommend ReadKey(-1) but # that means we need an infinite loop calling @@ -182,6 +181,16 @@ sub review_unused { last; } elsif ($response eq 'o') { system('xdg-open', $content_location); + } elsif ($response eq 'b' and $i > 0) { + pop @to_drop + if $to_drop[$#to_drop] eq + $unused_files[--$i]->{number}; + next UNUSED; + } elsif ($response eq 'd' and $i > 0) { + # user wants to drop the list we've + # accumulated up until now and get out of this + # script + last UNUSED; } else { say "invalid response"; } @@ -189,6 +198,7 @@ sub review_unused { } } say ""; + $i++; } $self->git->annex("dropunused", \%dropunused_args, @to_drop) if @to_drop; |