Merge pull request #706 from landaire/ctrlc_config

feat(cli): add `ctrlc_exit` config option
This commit is contained in:
Jonathan Turner 2019-09-26 09:22:11 +12:00 committed by GitHub
commit 7113c702ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -406,6 +406,18 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
}
LineResult::CtrlC => {
let config_ctrlc_exit = config::config(Tag::unknown())?
.get("ctrlc_exit")
.map(|s| match s.as_string().unwrap().as_ref() {
"true" => true,
_ => false,
})
.unwrap_or(false); // default behavior is to allow CTRL-C spamming similar to other shells
if !config_ctrlc_exit {
continue;
}
if ctrlcbreak {
let _ = rl.save_history(&History::path());
std::process::exit(0);