Skip to content

Commit

Permalink
Add a signal handler to reset the cursor on interrupt (#2603)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan Kelley <[email protected]>
  • Loading branch information
FragrantArmpit and jkelleyrtp authored Jul 23, 2024
1 parent 1dcfc44 commit 28d1b30
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ hyper-rustls = { workspace = true }
rustls = {version="0.23.11", default-features=false, features =["logging","std","tls12","ring"]}
subprocess = "0.2.9"
rayon = "1.8.0"
console = "0.15.8"
ctrlc = "3.2.3"
futures-channel = { workspace = true }
krates = { version = "0.17.0" }

axum = { workspace = true, features = ["ws"] }
axum-server = { workspace = true, features = ["tls-rustls"] }
axum-extra = { workspace = true, features = ["typed-header"] }
Expand All @@ -68,7 +71,6 @@ tower = { workspace = true }
once_cell = "1.19.0"

# plugin packages
ctrlc = "3.2.3"
open = "5.0.1"
cargo-generate = "=0.21.1"
toml_edit = "0.22.15"
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/src/cli/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ impl Create {
if self.yes && args.name.is_none() {
return Err("You have to provide the project's name when using `--yes` option.".into());
}
// https://github.com/console-rs/dialoguer/issues/294
ctrlc::set_handler(move || {
let _ = console::Term::stdout().show_cursor();
std::process::exit(0);
})
.expect("ctrlc::set_handler");
let path = cargo_generate::generate(args)?;
post_create(&path)
}
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/src/cli/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ impl Init {
let name = std::env::current_dir()?
.file_name()
.map(|f| f.to_str().unwrap().to_string());
// https://github.com/console-rs/dialoguer/issues/294
ctrlc::set_handler(move || {
let _ = console::Term::stdout().show_cursor();
std::process::exit(0);
})
.expect("ctrlc::set_handler");
let args = GenerateArgs {
define: self.option,
init: true,
Expand Down

0 comments on commit 28d1b30

Please sign in to comment.