work on review
This commit is contained in:
Generated
+4
-4
@@ -190,9 +190,9 @@ checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.49"
|
version = "1.0.50"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5"
|
checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
@@ -289,9 +289,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "termcolor"
|
name = "termcolor"
|
||||||
version = "1.1.3"
|
version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|||||||
+59
-36
@@ -47,53 +47,67 @@ pub(crate) fn review(todo_per_backend: ToDoPerBackend, groups: HashSet<Group>) -
|
|||||||
let backend = Rc::new(backend);
|
let backend = Rc::new(backend);
|
||||||
for package in packages {
|
for package in packages {
|
||||||
println!("{}: {package}", backend.get_section());
|
println!("{}: {package}", backend.get_section());
|
||||||
'inner: loop {
|
get_action_for_package(package, &groups, &mut reviews, &backend)?;
|
||||||
match ask_user_action_for_package()? {
|
|
||||||
ReviewAction::AsDependency => todo!(),
|
|
||||||
ReviewAction::AssignGroupBackend => {
|
|
||||||
if let Some((group, section)) = ask_user_group_section(&package, &groups)? {
|
|
||||||
reviews
|
|
||||||
.assign
|
|
||||||
.push((backend.clone(), package, &group, §ion));
|
|
||||||
break 'inner;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ReviewAction::Delete => {
|
|
||||||
reviews.delete.push((backend.clone(), package));
|
|
||||||
break 'inner;
|
|
||||||
}
|
|
||||||
ReviewAction::Info => backend.show_package_info(&package)?,
|
|
||||||
ReviewAction::Invalid => (),
|
|
||||||
ReviewAction::Skip => break 'inner,
|
|
||||||
ReviewAction::Quit => bail!("user wants to quit"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ask_user_group_section<'a>(
|
fn get_action_for_package(
|
||||||
package: &'a Package,
|
package: Package,
|
||||||
groups: &'a [Group],
|
groups: &[Group],
|
||||||
) -> Result<Option<(&'a Group, &'a Section)>> {
|
reviews: &mut Reviews,
|
||||||
if let Some(group) = ask_group(groups)? {
|
backend: &Rc<Box<dyn Backend>>,
|
||||||
if let Some(section_reply) = ask_section(&group.sections)? {
|
) -> Result<()> {
|
||||||
match section_reply {
|
loop {
|
||||||
SectionReply::Existing(section) => Ok(Some((group, section))),
|
match ask_user_action_for_package()? {
|
||||||
SectionReply::New(name) =>
|
ReviewAction::AsDependency => todo!(),
|
||||||
|
ReviewAction::AssignGroupBackend => {
|
||||||
|
if let Some(val) = assign_group_backend(&package, groups)? {
|
||||||
|
break;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return Ok(Some((group, section)));
|
ReviewAction::Delete => {
|
||||||
} else {
|
reviews.delete.push((backend.clone(), package));
|
||||||
return Ok(None);
|
break;
|
||||||
|
}
|
||||||
|
ReviewAction::Info => backend.show_package_info(&package)?,
|
||||||
|
ReviewAction::Invalid => (),
|
||||||
|
ReviewAction::Skip => break,
|
||||||
|
ReviewAction::Quit => bail!("user wants to quit"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ask_user_group_section(groups: &[Group]) -> Result<Option<GroupSectionReply>> {
|
||||||
|
let group = match ask_group(groups)? {
|
||||||
|
Some(group) => group,
|
||||||
|
None => return Ok(None),
|
||||||
|
};
|
||||||
|
|
||||||
|
let section_reply = match ask_section(&group.sections)? {
|
||||||
|
Some(reply) => reply,
|
||||||
|
None => return Ok(None),
|
||||||
|
};
|
||||||
|
|
||||||
|
let section = match section_reply {
|
||||||
|
SectionReply::Existing(section) => section,
|
||||||
|
SectionReply::New => return Ok(Some(GroupSectionReply::New)),
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Some(GroupSectionReply::Existing((group, section))))
|
||||||
|
}
|
||||||
|
|
||||||
|
enum GroupSectionReply<'a> {
|
||||||
|
Existing((&'a Group, &'a Section)),
|
||||||
|
New,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum SectionReply<'a> {
|
enum SectionReply<'a> {
|
||||||
Existing(&'a Section),
|
Existing(&'a Section),
|
||||||
New(String),
|
New,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ask_section(sections: &HashSet<Section>) -> Result<Option<SectionReply>> {
|
fn ask_section(sections: &HashSet<Section>) -> Result<Option<SectionReply>> {
|
||||||
@@ -112,8 +126,7 @@ fn ask_section(sections: &HashSet<Section>) -> Result<Option<SectionReply>> {
|
|||||||
if idx < sections.len() {
|
if idx < sections.len() {
|
||||||
Ok(Some(SectionReply::Existing(§ions[idx])))
|
Ok(Some(SectionReply::Existing(§ions[idx])))
|
||||||
} else if idx == sections.len() {
|
} else if idx == sections.len() {
|
||||||
let new_section_name = ask_new_section_name()?;
|
Ok(Some(SectionReply::New))
|
||||||
Ok(Some(SectionReply::New(new_section_name)))
|
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
@@ -187,3 +200,13 @@ fn ask_group(groups: &[Group]) -> Result<Option<&Group>> {
|
|||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn assign_group_backend(package: &Package, groups: &[Group]) -> Result<()> {
|
||||||
|
let reply = ask_user_group_section(groups)?;
|
||||||
|
match reply {
|
||||||
|
Some(val) => todo!(),
|
||||||
|
None => todo!(),
|
||||||
|
}
|
||||||
|
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user