fix error message on quitting review
This commit is contained in:
@@ -24,7 +24,6 @@ pub struct Pacdef {
|
|||||||
groups: HashSet<Group>,
|
groups: HashSet<Group>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO review
|
|
||||||
impl Pacdef {
|
impl Pacdef {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(args: ArgMatches, config: Config, groups: HashSet<Group>) -> Self {
|
pub fn new(args: ArgMatches, config: Config, groups: HashSet<Group>) -> Self {
|
||||||
|
|||||||
+13
-6
@@ -1,7 +1,7 @@
|
|||||||
use std::io::{self, stdin, stdout, Read, Write};
|
use std::io::{self, stdin, stdout, Read, Write};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use anyhow::{bail, Result};
|
use anyhow::Result;
|
||||||
use termios::*;
|
use termios::*;
|
||||||
|
|
||||||
use crate::backend::{Backend, ToDoPerBackend};
|
use crate::backend::{Backend, ToDoPerBackend};
|
||||||
@@ -56,7 +56,10 @@ pub(crate) fn review(
|
|||||||
let mut actions = vec![];
|
let mut actions = vec![];
|
||||||
for package in packages {
|
for package in packages {
|
||||||
println!("{}: {package}", backend.get_section());
|
println!("{}: {package}", backend.get_section());
|
||||||
get_action_for_package(package, &groups, &mut actions, &*backend)?;
|
match get_action_for_package(package, &groups, &mut actions, &*backend)? {
|
||||||
|
ContinueWithReview::Yes => continue,
|
||||||
|
ContinueWithReview::No => return Ok(()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reviews.0.push((backend, actions));
|
reviews.0.push((backend, actions));
|
||||||
}
|
}
|
||||||
@@ -88,7 +91,7 @@ fn get_action_for_package(
|
|||||||
groups: &[Rc<Group>],
|
groups: &[Rc<Group>],
|
||||||
reviews: &mut Vec<ReviewAction>,
|
reviews: &mut Vec<ReviewAction>,
|
||||||
backend: &dyn Backend,
|
backend: &dyn Backend,
|
||||||
) -> Result<()> {
|
) -> Result<ContinueWithReview> {
|
||||||
loop {
|
loop {
|
||||||
match ask_user_action_for_package()? {
|
match ask_user_action_for_package()? {
|
||||||
ReviewIntention::AsDependency => {
|
ReviewIntention::AsDependency => {
|
||||||
@@ -110,11 +113,15 @@ fn get_action_for_package(
|
|||||||
}
|
}
|
||||||
ReviewIntention::Invalid => (),
|
ReviewIntention::Invalid => (),
|
||||||
ReviewIntention::Skip => break,
|
ReviewIntention::Skip => break,
|
||||||
// TODO custom return type
|
ReviewIntention::Quit => return Ok(ContinueWithReview::No),
|
||||||
ReviewIntention::Quit => bail!("user wants to quit"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(ContinueWithReview::Yes)
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ContinueWithReview {
|
||||||
|
Yes,
|
||||||
|
No,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ask_user_action_for_package() -> Result<ReviewIntention> {
|
fn ask_user_action_for_package() -> Result<ReviewIntention> {
|
||||||
|
|||||||
Reference in New Issue
Block a user