diff --git a/src/main.rs b/src/main.rs index a8b8618..b3181e9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -121,6 +121,7 @@ fn run_cargo_build( toolchain: Option, project: &PathBuf, release: bool, + cargo_option: &str, ) -> Result { let mut cargo = Command::new("cargo"); @@ -131,7 +132,9 @@ fn run_cargo_build( let cargo = cargo .arg("run") .arg("--manifest-path") - .arg(project.join("Cargo.toml")); + .arg(project.join("Cargo.toml")) + // FIXME: proper escaping + .args(cargo_option.split_ascii_whitespace()); if release { cargo.arg("--release"); @@ -186,7 +189,7 @@ fn main() -> Result<(), CargoPlayError> { write_cargo_toml(&temp, src_hash.clone(), dependencies, opt.edition)?; copy_sources(&temp, &opt.src)?; - match run_cargo_build(opt.toolchain, &temp, opt.release)?.code() { + match run_cargo_build(opt.toolchain, &temp, opt.release, &opt.cargo_option)?.code() { Some(code) => std::process::exit(code), None => std::process::exit(-1), } diff --git a/src/opt.rs b/src/opt.rs index 2bf2b1e..0016f85 100644 --- a/src/opt.rs +++ b/src/opt.rs @@ -68,6 +68,9 @@ pub(crate) struct Opt { pub release: bool, #[structopt(long = "cached", hidden = true)] pub cached: bool, + #[structopt(long = "cargo-option")] + /// Custom flags passing to cargo + pub cargo_option: String, #[structopt(multiple = true, last = true)] /// Arguments passed to the underlying program pub args: Vec,