From 81dccd57f5e3f73917c0f865e9d3a2c39c3b53f5 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 26 Dec 2024 13:00:37 +0100 Subject: [PATCH] feat(import): Add support for quitting in candidate selection screen --- src/cli/import.rs | 1 + src/cli/ui/select_candidate.rs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/cli/import.rs b/src/cli/import.rs index b67a907..fdf0d07 100644 --- a/src/cli/import.rs +++ b/src/cli/import.rs @@ -144,6 +144,7 @@ async fn select_release<'a>( ui::ReleaseCandidateSelectionResult::Skipped => { return Ok(SelectionResult::Skipped) } + ui::ReleaseCandidateSelectionResult::Quit => return Ok(SelectionResult::Quit), }; }; allow_autoselection = false; diff --git a/src/cli/ui/select_candidate.rs b/src/cli/ui/select_candidate.rs index ecae507..e763f79 100644 --- a/src/cli/ui/select_candidate.rs +++ b/src/cli/ui/select_candidate.rs @@ -34,6 +34,8 @@ pub enum ReleaseCandidateSelectionResult<'a, T: ReleaseLike> { /// Save release information to file (for debugging). #[cfg(feature = "dev")] DumpReleaseInfo, + /// Quit (i.e., skip this item and all following). + Quit, } /// An option presented when selecting a release. @@ -49,6 +51,8 @@ enum ReleaseCandidateSelectionOption<'a, T: ReleaseLike> { DumpReleaseInfo, /// Skip this item. SkipItem, + /// Quit (i.e., skip this item and all following). + Quit, } // Manual implementation of `Clone` to work around unnecessary trait bound `T: Clone`. @@ -61,6 +65,7 @@ impl Clone for ReleaseCandidateSelectionOption<'_, T> { #[cfg(feature = "dev")] Self::DumpReleaseInfo => Self::DumpReleaseInfo, Self::SkipItem => Self::SkipItem, + Self::Quit => Self::Quit, } } } @@ -141,6 +146,7 @@ impl fmt::Display for StyledReleaseCandidateSelectionOption<'_, ReleaseCandidateSelectionOption::PrintTrackList => "Print Tracklist", #[cfg(feature = "dev")] ReleaseCandidateSelectionOption::DumpReleaseInfo => "Dump Releases for Debugging", + ReleaseCandidateSelectionOption::Quit => "Quit", ReleaseCandidateSelectionOption::Candidate(_) => unreachable!(), }; write!( @@ -192,6 +198,7 @@ pub fn select_candidate<'a, T: ReleaseLike>( #[cfg(feature = "dev")] ReleaseCandidateSelectionOption::DumpReleaseInfo, ReleaseCandidateSelectionOption::SkipItem, + ReleaseCandidateSelectionOption::Quit, ]; let options: Vec> = candidates .iter() @@ -227,6 +234,9 @@ pub fn select_candidate<'a, T: ReleaseLike>( | Err(InquireError::OperationCanceled) => { break Ok(ReleaseCandidateSelectionResult::Skipped) } + Ok(ReleaseCandidateSelectionOption::Quit) => { + break Ok(ReleaseCandidateSelectionResult::Quit) + } Err(err) => Err(err)?, } }