diff --git a/cargo-trust/src/main.rs b/cargo-trust/src/main.rs index 5e7ce7007c1c80338a716fd02f99b611bdd06c81..432703cddba42b449c6408f962a78426c18abef5 100644 --- a/cargo-trust/src/main.rs +++ b/cargo-trust/src/main.rs @@ -66,24 +66,27 @@ fn run() -> Result<i32, failure::Error> { let mut args = std::env::args(); // When called by Cargo, the first argument after the binary name will be `trust`. - if env::args().nth(1) == Some("trust".to_string()) { - args.next(); - } else { + if env::args().nth(1) != Some("trust".to_string()) { panic!("internal error"); } - let mut args: Vec<_> = args.collect(); - args.remove(0); // Remove executable name + args.next(); // remove filename - // Get command line options. + let args: Vec<_> = args.collect(); + // Get command line options. Removes 1st arg ("trust") by default let opt = Opt::from_iter(&args); - println!("args {:?}", args); - let mut cargo = Command::new("cargo"); // forwarding of user arguments - cargo.arg("rustc").args(args); + cargo.arg("rustc"); + if let Some(bin) = &opt.bin { + cargo.args(&["--bin", bin]); + } + + if let Some(example) = &opt.example { + cargo.args(&["--example", &example]); + } // klee specifics cargo @@ -108,7 +111,6 @@ fn run() -> Result<i32, failure::Error> { if !status.success() { panic!("cargo trust command failed!"); - // handle_failed_command(status) } // Try and get the cargo project information.