Skip to content

Commit

Permalink
Merge pull request #581 from danakj/cargo-arg
Browse files Browse the repository at this point in the history
Add --cargo-arg option for arguments to pass through to cargo
  • Loading branch information
mystor authored Dec 1, 2023
2 parents b2ef07b + 3b99964 commit 03ae094
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ pub struct Cli {
#[clap(help_heading = "GLOBAL OPTIONS", global = true)]
pub filter_graph: Option<Vec<GraphFilter>>,

/// Arguments to pass through to cargo. It can be specified multiple times for
/// multiple arguments.
///
/// Example: `--cargo-arg=-Zbindeps`
///
/// This allows using unstable options in Cargo if a project's Cargo.toml requires them.
#[clap(long, action)]
#[clap(help_heading = "GLOBAL OPTIONS", global = true)]
pub cargo_arg: Vec<String>,

// Args for `Check` when the subcommand is not explicitly specified.
//
// These are exclusive with specifying a subcommand due to
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ fn real_main() -> Result<(), miette::Report> {
{
other_options.push("--color=always".to_string());
}
other_options.extend(cli.cargo_arg.iter().cloned());
cmd.other_options(other_options);

info!("Running: {:#?}", cmd.cargo_command());
Expand Down
9 changes: 9 additions & 0 deletions tests/snapshots/test_cli__long-help.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: tests/test-cli.rs
assertion_line: 104
expression: format_outputs(&output)
---
stdout:
Expand Down Expand Up @@ -125,6 +126,14 @@ GLOBAL OPTIONS:
* `is_dev_only($bool)`: whether it's only used by dev (test) builds in the original
graph

--cargo-arg <CARGO_ARG>
Arguments to pass through to cargo. It can be specified multiple times for multiple
arguments.

Example: `--cargo-arg=-Zbindeps`

This allows using unstable options in Cargo if a project's Cargo.toml requires them.

SUBCOMMANDS:
check
\[default\] Check that the current project has been vetted
Expand Down
9 changes: 9 additions & 0 deletions tests/snapshots/test_cli__markdown-help.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: tests/test-cli.rs
assertion_line: 134
expression: format_outputs(&output)
---
stdout:
Expand Down Expand Up @@ -134,6 +135,14 @@ tested)
* `is_dev_only($bool)`: whether it's only used by dev (test) builds in the original
graph
#### `--cargo-arg <CARGO_ARG>`
Arguments to pass through to cargo. It can be specified multiple times for multiple
arguments.
Example: `--cargo-arg=-Zbindeps`
This allows using unstable options in Cargo if a project's Cargo.toml requires them.
### SUBCOMMANDS
* [check](#cargo-vet-check): \[default\] Check that the current project has been vetted
* [suggest](#cargo-vet-suggest): Suggest some low-hanging fruit to review
Expand Down
5 changes: 5 additions & 0 deletions tests/snapshots/test_cli__short-help.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: tests/test-cli.rs
assertion_line: 119
expression: format_outputs(&output)
---
stdout:
Expand Down Expand Up @@ -63,6 +64,10 @@ GLOBAL OPTIONS:
--filter-graph <FILTER_GRAPH>
Filter out different parts of the build graph and pretend that's the true graph

--cargo-arg <CARGO_ARG>
Arguments to pass through to cargo. It can be specified multiple times for multiple
arguments

SUBCOMMANDS:
check \[default\] Check that the current project has been vetted
suggest Suggest some low-hanging fruit to review
Expand Down

0 comments on commit 03ae094

Please sign in to comment.