Skip to content

Commit

Permalink
Support ctrl+c (#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanheule authored Sep 3, 2024
1 parent b1256c8 commit d24ceef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ log = "0.4.16"
env_logger = "0.10.0"
tempdir = "0.3"
serde_json = "1.0.82"
ctrlc = "3.4"

# TODO: Update if we upgrade tree-sitter to >=0.21
tree-sitter-kotlin = "=0.3.5"
Expand Down
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

//! Defines the entry-point for Piranha.
use std::{fs, time::Instant};
use std::{fs, process, time::Instant};

use log::{debug, info};
use polyglot_piranha::{
Expand All @@ -21,6 +21,13 @@ use polyglot_piranha::{
};

fn main() {
// Set up the Ctrl+C handler
ctrlc::set_handler(move || {
println!("Received Ctrl+C! Exiting...");
process::exit(130);
})
.expect("Error setting Ctrl+C handler");

let now = Instant::now();
env_logger::init();

Expand Down

0 comments on commit d24ceef

Please sign in to comment.