Skip to content

Commit a4dd463

Browse files
committed
Keep MiriCommand out of ask_to_run function
1 parent 2584507 commit a4dd463

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/bin/cargo-miri.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,9 @@ fn xargo_version() -> Option<(u32, u32, u32)> {
247247
Some((major, minor, patch))
248248
}
249249

250-
fn ask_to_run(mut cmd: Command, subcommand: MiriCommand, text: &str) {
250+
fn ask_to_run(mut cmd: Command, ask: bool, text: &str) {
251251
// Disable interactive prompts in CI (GitHub Actions, Travis, AppVeyor, etc).
252-
let ask = subcommand != MiriCommand::Setup && env::var_os("CI").is_none();
253-
if ask {
252+
if ask && env::var_os("CI").is_none() {
254253
let mut buf = String::new();
255254
print!("I will run `{:?}` to {}. Proceed? [Y/n] ", cmd, text);
256255
io::stdout().flush().unwrap();
@@ -281,6 +280,10 @@ fn setup(subcommand: MiriCommand) {
281280
return;
282281
}
283282

283+
// Subcommands other than `setup` will do a setup if necessary, but
284+
// interactively confirm first.
285+
let ask_user = subcommand != MiriCommand::Setup;
286+
284287
// First, we need xargo.
285288
if xargo_version().map_or(true, |v| v < XARGO_MIN_VERSION) {
286289
if std::env::var("XARGO_CHECK").is_ok() {
@@ -289,7 +292,7 @@ fn setup(subcommand: MiriCommand) {
289292
}
290293
let mut cmd = cargo();
291294
cmd.args(&["install", "xargo", "-f"]);
292-
ask_to_run(cmd, subcommand, "install a recent enough xargo");
295+
ask_to_run(cmd, ask_user, "install a recent enough xargo");
293296
}
294297

295298
// Determine where the rust sources are located. `XARGO_RUST_SRC` env var trumps everything.
@@ -312,7 +315,7 @@ fn setup(subcommand: MiriCommand) {
312315
cmd.args(&["component", "add", "rust-src"]);
313316
ask_to_run(
314317
cmd,
315-
subcommand,
318+
ask_user,
316319
"install the rustc-src component for the selected toolchain",
317320
);
318321
}

0 commit comments

Comments
 (0)