feat: allow ignoring failed commands (#1957)

* feat: allow ignoring failed commands

* cleanup
This commit is contained in:
Ellie Huxtable 2024-04-18 08:18:15 +01:00 committed by GitHub
parent cb19925011
commit 2fba4aae93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -370,6 +370,7 @@ pub struct Settings {
pub scroll_context_lines: usize,
pub history_format: String,
pub prefers_reduced_motion: bool,
pub store_failed: bool,
#[serde(with = "serde_regex", default = "RegexSet::empty")]
pub history_filter: RegexSet,
@ -645,6 +646,7 @@ impl Settings {
.set_default("keymap_mode_shell", "auto")?
.set_default("keymap_cursor", HashMap::<String, String>::new())?
.set_default("smart_sort", false)?
.set_default("store_failed", true)?
.set_default(
"prefers_reduced_motion",
std::env::var("NO_MOTION")

View File

@ -348,6 +348,15 @@ impl Cmd {
return Ok(());
}
if !settings.store_failed && h.exit != 0 {
debug!("history has non-zero exit code, and store_failed is false");
// the history has already been inserted half complete. remove it
db.delete(h).await?;
return Ok(());
}
h.exit = exit;
h.duration = match duration {
Some(value) => i64::try_from(value).context("command took over 292 years")?,