Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'apply' option to review #61

Merged
merged 1 commit into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/pacdef_core/src/review/datastructures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub(super) enum ReviewIntention {
Invalid,
Skip,
Quit,
Apply,
}

#[derive(Debug)]
Expand Down Expand Up @@ -88,6 +89,7 @@ impl IntoIterator for ReviewsPerBackend {
pub(super) enum ContinueWithReview {
Yes,
No,
NoAndApply,
}

fn extract_actions(
Expand Down
5 changes: 4 additions & 1 deletion crates/pacdef_core/src/review/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub fn review(
match get_action_for_package(package, &groups, &mut actions, &*backend)? {
ContinueWithReview::Yes => continue,
ContinueWithReview::No => return Ok(()),
ContinueWithReview::NoAndApply => break,
}
}
reviews.push((backend, actions));
Expand Down Expand Up @@ -101,6 +102,7 @@ fn get_action_for_package(
ReviewIntention::Invalid => (),
ReviewIntention::Skip => break,
ReviewIntention::Quit => return Ok(ContinueWithReview::No),
ReviewIntention::Apply => return Ok(ContinueWithReview::NoAndApply),
}
}
Ok(ContinueWithReview::Yes)
Expand All @@ -122,6 +124,7 @@ fn ask_user_action_for_package(supports_as_dependency: bool) -> Result<ReviewInt
'i' => Ok(ReviewIntention::Info),
'q' => Ok(ReviewIntention::Quit),
's' => Ok(ReviewIntention::Skip),
'p' => Ok(ReviewIntention::Apply),
_ => Ok(ReviewIntention::Invalid),
}
}
Expand All @@ -140,7 +143,7 @@ fn print_query(supports_as_dependency: bool) -> Result<()> {
query.push_str("(a)s dependency, ");
}

query.push_str("(q)uit? ");
query.push_str("a(p)ply, (q)uit? ");

print!("{query}");
stdout().lock().flush()?;
Expand Down
Loading