Add a signal handler to reset the cursor on interrupt (#2603)

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
FragrantArmpitandJonathan Kelley authored and GitHub committed 2024-07-23 11:00:57 -07:00
1 parent 1dcfc44c23
commit 28d1b305c4
4 files changed
+16 -1

No files matched your search

+6
View File
@@ -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)
}
+6
View File
@@ -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,