Skip to content

Commit

Permalink
Do not print Error when ctrl+c or Esc
Browse files Browse the repository at this point in the history
  • Loading branch information
Baarsgaard committed Jan 14, 2024
1 parent bba23c1 commit 3e3ee3b
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions jig-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use color_eyre::owo_colors::OwoColorize;
use commands::{shared::ExecCommand, *};
use config::Config;
use hooks::{is_git_hook, Hook};
use inquire::InquireError;

#[derive(Parser)]
#[command(author, version, about = "A Jira CLI integration with Git", long_about = None)]
Expand Down Expand Up @@ -86,13 +87,27 @@ fn main() -> Result<()> {
match githook.exec(&cfg?) {
Ok(_) => (),
Err(e) => {
// Add better comments from old hook
eprintln!("{}", format!("Error:\n {}", e).bright_red());
std::process::exit(1);
match e.root_cause().downcast_ref::<InquireError>() {
Some(InquireError::OperationInterrupted)
| Some(InquireError::OperationCanceled) => std::process::exit(1),
_ => {
// Add better comments from old hook
eprintln!("{}", format!("Error:\n {}", e).bright_red());
std::process::exit(1);
}
}
}
}
} else {
println!("{}", Commands::exec(cfg)?);
let res = Commands::exec(cfg);
match res {
Ok(msg) => println!("{}", msg),
Err(e) => match e.root_cause().downcast_ref::<InquireError>() {
Some(InquireError::OperationInterrupted)
| Some(InquireError::OperationCanceled) => std::process::exit(1),
_ => Err(e)?,
},
}
};

// Fix windows prompt overriding last line of output
Expand Down

0 comments on commit 3e3ee3b

Please sign in to comment.