forked from DGNum/colmena
Fix --nix-option
flag
This commit is contained in:
parent
5e17c629b2
commit
fc5c6d4544
2 changed files with 7 additions and 20 deletions
12
src/cli.rs
12
src/cli.rs
|
@ -127,7 +127,6 @@ struct Opts {
|
|||
impure: bool,
|
||||
#[arg(
|
||||
long,
|
||||
value_parser = crate::util::parse_key_val::<String, String>,
|
||||
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<String>,
|
||||
#[arg(
|
||||
long,
|
||||
value_name = "WHEN",
|
||||
|
@ -263,8 +262,11 @@ async fn get_hive(opts: &Opts) -> ColmenaResult<Hive> {
|
|||
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)
|
||||
|
|
15
src/util.rs
15
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<T, U>(s: &str) -> Result<(T, U), Box<dyn Error + Send + Sync + 'static>>
|
||||
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<R>(
|
||||
mut stream: BufReader<R>,
|
||||
job: Option<JobHandle>,
|
||||
|
|
Loading…
Reference in a new issue