Skip to content

Commit 2d622bb

Browse files
committed
launcher: Await user input on error
Previously, if the Godot editor failed to launch (perhaps because it has not been downloaded!), the terminal window would disappear too quickly for the error message to be legible. Add the same "Press Enter to continue..." prompt as in the updater, but only in the error case. Handle two error paths: - The process could not be spawned - The process was spawned but exited with a non-zero status
1 parent 1593a91 commit 2d622bb

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

launch-patchwork/src/main.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
use std::io;
22
use std::process::Command;
33

4+
fn await_confirmation() -> () {
5+
println!("Press Enter to continue...");
6+
let mut input = String::new();
7+
std::io::stdin().read_line(&mut input).unwrap();
8+
}
9+
410
fn main() -> io::Result<()> {
511
// TODO: make this cross-platform
612
let godot = std::env::current_dir()?.join("./godot_editor/godot.windows.editor.x86_64.exe");
713

814
println!("Launching Godot from {:?}...", godot);
915

10-
let status = Command::new(godot)
16+
match Command::new(godot)
1117
.arg("-e")
1218
.arg("--path")
1319
.arg(".")
14-
.status()?;
15-
16-
if status.success() {
17-
println!("Godot editor launched successfully.");
18-
} else {
19-
println!("Godot editor exited with: {}", status);
20-
}
20+
.status() {
21+
Ok(status) if status.success() => {
22+
println!("Godot editor launched successfully.");
23+
}
24+
Ok(status) => {
25+
println!("Godot editor exited with: {}", status);
26+
await_confirmation();
27+
}
28+
Err(e) => {
29+
println!("Failed to launch Godot: {}", e);
30+
await_confirmation();
31+
}
32+
}
2133

2234
Ok(())
2335
}

0 commit comments

Comments
 (0)