Skip to content

Commit

Permalink
Allow multiple -d/--dep
Browse files Browse the repository at this point in the history
Using repeated -d/--dep was broken in the clap upgrade.

Fixes #106.
  • Loading branch information
fornwall committed Jun 12, 2023
1 parent b719859 commit 847f679
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ impl Args {
.help("Add a dependency - either just the package name (for the latest version) or as `name=version`")
.long("dep")
.short('d')
.num_args(1..)
.number_of_values(1)
.action(ArgAction::Append)
)
.arg(Arg::new("extern")
.help("Adds an `#[macro_use] extern crate name;` item for expressions and loop scripts")
Expand Down
5 changes: 5 additions & 0 deletions tests/data/script-using-anyhow-and-serde.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;
use serde_json::from_str;

println!("--output--");
println!("Ok");
17 changes: 17 additions & 0 deletions tests/tests/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,20 @@ fn test_extern_c_main() {
)
.unwrap()
}

#[test]
#[cfg_attr(not(feature = "online_tests"), ignore)]
fn test_script_multiple_deps() {
let out = rust_script!(
"-d",
"serde_json=1.0.96",
"-d",
"anyhow=1.0.71",
"tests/data/script-using-anyhow-and-serde.rs"
)
.unwrap();
scan!(out.stdout_output();
("Ok") => ()
)
.unwrap()
}

0 comments on commit 847f679

Please sign in to comment.