From 8e64d354c3fdf029f92cc4edfc25046f5241240a Mon Sep 17 00:00:00 2001 From: r0r-5chach Date: Sun, 21 Jul 2024 20:22:47 +0100 Subject: [PATCH] fixed keyboard interrupt --- Cargo.lock | 29 +++++++++++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 6 +++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index ad7fd85..aecde24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,6 +62,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "clap" version = "4.4.13" @@ -118,6 +124,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "ctrlc" +version = "3.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345" +dependencies = [ + "nix", + "windows-sys 0.52.0", +] + [[package]] name = "errno" version = "0.3.9" @@ -169,6 +185,18 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "nix" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +dependencies = [ + "bitflags", + "cfg-if", + "cfg_aliases", + "libc", +] + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -271,6 +299,7 @@ version = "0.1.0" dependencies = [ "clap", "colored", + "ctrlc", "rand", "tempfile", ] diff --git a/Cargo.toml b/Cargo.toml index e95d587..8ee2c15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ publish = ["gitea"] [dependencies] clap = { version = "4.4.12", features = ["derive"] } +ctrlc = "3.4.4" colored = "2.1.0" rand = "0.8.5" diff --git a/src/main.rs b/src/main.rs index a578ec0..a0ed445 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,8 @@ /// Entrypoint for the main binary. fn main() { + ctrlc::set_handler(move || { + println!(); + std::process::exit(1); + }).unwrap(); term_header::run(); -} +} //TODO: Handle all unwraps