Skip to content

Commit

Permalink
Add --cargo-opt= option for passing global options to cargo
Browse files Browse the repository at this point in the history
  • Loading branch information
ijackson committed Oct 10, 2020
1 parent 426400a commit ccd0364
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ impl GlobalOpts {
/// The caller should use `.args` to specify the cargo subcommand,
/// and set the current directory, and so on.
pub fn cargo_cmd(&self) -> std::process::Command {
std::process::Command::new("cargo")
let mut cmd = std::process::Command::new("cargo");
cmd.args(&self.cargo_opt);
cmd
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,9 @@ pub struct Cli {
#[derive(Debug, StructOpt)]
/// Global options, passed to every subcommand.
pub struct GlobalOpts {
/// Additional global argument to pass to `cargo`, before the cargo subcommand.
/// For example, `--cargo-opt=--locked`.
/// May be repeated to pass multiple options.
#[structopt(long="cargo-opt", number_of_values = 1)]
pub cargo_opt: Vec<String>,
}

0 comments on commit ccd0364

Please sign in to comment.