summaryrefslogtreecommitdiffhomepage
path: root/src/opt.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/opt.rs')
-rw-r--r--src/opt.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/opt.rs b/src/opt.rs
index 724b131..0782163 100644
--- a/src/opt.rs
+++ b/src/opt.rs
@@ -86,6 +86,21 @@ impl std::fmt::Display for SegmentOrder {
}
}
+#[cfg(windows)]
+fn pause() {
+ println!("Press any key to exit...");
+
+ unsafe extern "C" { fn _getch() -> i32; }
+ unsafe { _getch(); }
+}
+
+/// pause before exit on windows to print information in
+/// console before it is closed.
+fn paexit(code: i32) {
+ #[cfg(windows)] pause();
+ std::process::exit(code);
+}
+
static OPT_DAEMON: OnceLock<bool> = OnceLock::new();
static OPT_LOG_LEVEL: OnceLock<LogLevel> = OnceLock::new();
static OPT_NO_SPLASH: OnceLock<bool> = OnceLock::new();
@@ -151,7 +166,7 @@ impl Opt {
let argv = arg.as_str();
match argv {
- "-h" | "--help" => { usage(); std::process::exit(0); }
+ "-h" | "--help" => { usage(); paexit(0); }
"-d" | "-D" | "--daemon" => {
if argv == "-D" && !warned_daemon_deprecated {
// FIXME(on release): remove this on v1.0.0