diff --git a/src/cli.rs b/src/cli.rs index aec55e5..ebfebcd 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -127,7 +127,6 @@ struct Opts { impure: bool, #[arg( long, - value_parser = crate::util::parse_key_val::, help = "Passes an arbitrary option to Nix commands", long_help = r#"Passes arbitrary options to Nix commands @@ -135,9 +134,9 @@ This only works when building locally. "#, global = true, num_args = 2, - value_names = ["NAME, VALUE"], + value_names = ["NAME", "VALUE"], )] - nix_option: Vec<(String, String)>, + nix_option: Vec, #[arg( long, value_name = "WHEN", @@ -263,8 +262,11 @@ async fn get_hive(opts: &Opts) -> ColmenaResult { hive.set_impure(true); } - for (name, value) in opts.nix_option.iter().cloned() { - hive.add_nix_option(name, value); + for chunks in opts.nix_option.chunks_exact(2) { + let [name, value] = chunks else { + unreachable!() + }; + hive.add_nix_option(name.clone(), value.clone()); } Ok(hive) diff --git a/src/util.rs b/src/util.rs index 1a07f9a..ffbfef5 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,5 +1,4 @@ use std::convert::TryFrom; -use std::error::Error; use std::process::Stdio; @@ -192,20 +191,6 @@ impl CommandExt for CommandExecution { } } -/// Parse a single key-value pair -pub fn parse_key_val(s: &str) -> Result<(T, U), Box> -where - T: std::str::FromStr, - T::Err: Error + Send + Sync + 'static, - U: std::str::FromStr, - U::Err: Error + Send + Sync + 'static, -{ - let pos = s - .find('=') - .ok_or_else(|| format!("invalid KEY=value: no `=` found in `{s}`"))?; - Ok((s[..pos].parse()?, s[pos + 1..].parse()?)) -} - pub async fn capture_stream( mut stream: BufReader, job: Option,