feat: warn about missing group only when relevant
So far we have warned the user when we first visited the group dir and there were no group files. This lead to spurious warnings, e.g. when the user wanted to import or create a group. We now defer the check to when we actually need some content in the groups, and the program should not perform the respective action without any groups present. This causes some code duplication, but enhances UE. Closes #31.
This commit is contained in:
@@ -17,6 +17,11 @@ use crate::grouping::{Group, Package, Section};
|
||||
/// - an invalid regex was provided, or
|
||||
/// - no matching packages could be found.
|
||||
pub fn search_packages(regex_str: &str, groups: &HashSet<Group>) -> Result<()> {
|
||||
if groups.is_empty() {
|
||||
eprintln!("WARNING: no group files found");
|
||||
bail!(crate::errors::Error::NoPackagesFound);
|
||||
}
|
||||
|
||||
let re = Regex::new(regex_str)?;
|
||||
|
||||
let mut vec = vec![];
|
||||
|
||||
Reference in New Issue
Block a user