Skip to content

Commit 9e640e5

Browse files
committed
Update clap to 1.4.5, work around rust-lang/rust#29166.
1 parent c5961aa commit 9e640e5

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ time = "0.1.25"
1414
toml = "0.1.20"
1515

1616
[dependencies.clap]
17-
version = "0.10.2"
17+
version = "1.4.5"
1818

1919
# Disable the "color" feature because it just outputs garbage on Windows.
2020
default-features = false

src/main.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn parse_args() -> Args {
8383
.about(about)
8484
.arg_required_else_help(true)
8585
.subcommand_required_else_help(true)
86-
.subcommand(SubCommand::new("script")
86+
.subcommand(SubCommand::with_name("script")
8787
.version(version)
8888
.about(about)
8989
.usage("cargo script [FLAGS OPTIONS] [--] <script> <args>...")
@@ -111,7 +111,7 @@ fn parse_args() -> Args {
111111
.requires("script")
112112
)
113113
.arg_group(ArgGroup::with_name("expr_or_loop")
114-
.add_all(vec!["expr", "loop"])
114+
.add_all(&["expr", "loop"])
115115
)
116116
.arg(Arg::with_name("clear_cache")
117117
.help("Clears out the script cache.")
@@ -182,10 +182,13 @@ fn parse_args() -> Args {
182182

183183
let m = m.subcommand_matches("script").unwrap();
184184

185+
fn owned_vec_string<'a>(v: Option<Vec<&'a str>>) -> Vec<String> {
186+
v.unwrap_or(vec![]).into_iter().map(Into::into).collect()
187+
}
188+
185189
Args {
186190
script: m.value_of("script").map(Into::into),
187-
args: m.values_of("args").unwrap_or(vec![]).into_iter()
188-
.map(Into::into).collect(),
191+
args: owned_vec_string(m.values_of("args")),
189192

190193
expr: m.is_present("expr"),
191194
loop_: m.is_present("loop"),
@@ -196,12 +199,9 @@ fn parse_args() -> Args {
196199
build_only: m.is_present("build_only"),
197200
clear_cache: m.is_present("clear_cache"),
198201
debug: m.is_present("debug"),
199-
dep: m.values_of("dep").unwrap_or(vec![]).into_iter()
200-
.map(Into::into).collect(),
201-
dep_extern: m.values_of("dep_extern").unwrap_or(vec![]).into_iter()
202-
.map(Into::into).collect(),
203-
extern_: m.values_of("extern").unwrap_or(vec![]).into_iter()
204-
.map(Into::into).collect(),
202+
dep: owned_vec_string(m.values_of("dep")),
203+
dep_extern: owned_vec_string(m.values_of("dep_extern")),
204+
extern_: owned_vec_string(m.values_of("extern")),
205205
force: m.is_present("force"),
206206
}
207207
}

0 commit comments

Comments
 (0)