diff --git a/Cargo.lock b/Cargo.lock index 5f5429f..ad86311 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -414,7 +414,7 @@ dependencies = [ [[package]] name = "sccmod" -version = "0.6.0" +version = "0.6.1" dependencies = [ "anstyle", "clap", diff --git a/Cargo.toml b/Cargo.toml index d482cc8..b060450 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sccmod" authors = ["Toby Davis \"Pencilcaseman\""] -version = "0.6.0" +version = "0.6.1" edition = "2021" readme = "README.md" license = "MIT OR Apache-2.0" diff --git a/rustfmt.toml b/rustfmt.toml index b976ea9..33fc833 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,6 +1,9 @@ use_small_heuristics = "Max" max_width = 80 +comment_width = 80 +wrap_comments = true + unstable_features = true imports_granularity = "Crate" group_imports = "StdExternalCrate" diff --git a/src/callbacks.rs b/src/callbacks.rs index 93a230f..7efcd34 100644 --- a/src/callbacks.rs +++ b/src/callbacks.rs @@ -88,7 +88,8 @@ pub fn resolver_boilerplate( } } - selection.clear(); // Clear the input buffer for the next iteration + selection.clear(); // Clear the input buffer for the next + // iteration } if all { @@ -104,6 +105,14 @@ pub fn resolver_boilerplate( module_resolver::ResolveMatch::None => { log::error("No modules match the partials provided"); } + + module_resolver::ResolveMatch::All(m) => { + for module in &m { + func(module)?; + } + + Ok(()) + } } } diff --git a/src/module_resolver.rs b/src/module_resolver.rs index e14e655..bef0524 100644 --- a/src/module_resolver.rs +++ b/src/module_resolver.rs @@ -6,6 +6,7 @@ use crate::{ pub enum ResolveMatch { Full(Module), Partial(Vec), + All(Vec), None, } @@ -16,6 +17,17 @@ pub enum ResolveMatch { /// # Errors /// Will error if the modules cannot be listed. pub fn resolve(partials: &[&str]) -> Result { + // Allow passing `ALL` as the last argument to install all matching + // modules + + let mut partials = partials.to_vec(); + let mut all = false; + if partials[partials.len() - 1] == "ALL" { + // Remove `--all` from the list of partials + partials.pop(); + all = true; + } + let mut results: Vec = get_modules()? .into_iter() .filter(|module| { @@ -34,6 +46,7 @@ pub fn resolve(partials: &[&str]) -> Result { || log::error("An internal error has occurred"), |x| x, ))), - _ => Ok(ResolveMatch::Partial(results)), + _ if !all => Ok(ResolveMatch::Partial(results)), + _ => Ok(ResolveMatch::All(results)), } }