From fd3989e1fba704e8cece4ff68c14814d272bdc75 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 22 Mar 2020 09:38:52 -0700 Subject: annex-review-unused: Add missing prompt_yn subroutine Signed-off-by: Sean Whitton --- Changes | 1 + lib/App/annex_review_unused.pm | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Changes b/Changes index b27b32f..fd88f5d 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for Git::Annex {{$NEXT}} + - annex-review-unused: Add missing prompt_yn subroutine. 0.004 2020-03-18 17:08:57-07:00 America/Phoenix - annex-to-annex-dropunused: Fix attempt to call wrong main() diff --git a/lib/App/annex_review_unused.pm b/lib/App/annex_review_unused.pm index 2527193..340c17f 100644 --- a/lib/App/annex_review_unused.pm +++ b/lib/App/annex_review_unused.pm @@ -192,6 +192,19 @@ sub _say_bullet { _say_bold(" • ", @_) } sub _say_spaced_bullet { _say_bold("\n", " • ", @_, "\n") } +sub prompt_yn { + my $prompt = shift; + local $| = 1; + my $response; + while (1) { + print colored(['bold'], "$prompt "); + chomp(my $response = ); + return 1 if lc($response) eq "y"; + return 0 if lc($response) eq "n"; + say "invalid response"; + } +} + sub exit { $exit_main = shift // 0; goto EXIT_MAIN } 1; -- cgit v1.2.3