diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2024-03-29 09:23:06 -0400 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2024-03-29 09:23:29 -0400 |
commit | a103c88642514c7463ab0e501f2a8271f1b72327 (patch) | |
tree | 464a7e07de9b32a04d4c5810a683f6992fe26507 | |
parent | 2493c9d9bdf422a95dc75cff8ece8c5dcfad6275 (diff) |
add back confirm_exit option
- pager seems a little buggy at the moment with long running processes
or processes that have a lot of output
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/config/clean/mimetype/entry.rs | 11 | ||||
-rw-r--r-- | src/util/process.rs | 10 |
3 files changed, 19 insertions, 4 deletions
@@ -36,7 +36,7 @@ ratatui-image = { version = "0.8.1", default-features = false, features = ["term regex = "1.9.3" rustyline = "^12" serde = { version = "^1", features = ["derive"] } -shadow-rs = "0.26" +shadow-rs = "^0" shell-words = "^1" shellexpand = { version = "^3", features = ["full"] } signal-hook = "^0" diff --git a/src/config/clean/mimetype/entry.rs b/src/config/clean/mimetype/entry.rs index ee18998..378012d 100644 --- a/src/config/clean/mimetype/entry.rs +++ b/src/config/clean/mimetype/entry.rs @@ -12,6 +12,8 @@ pub struct ProgramEntry { _fork: bool, #[serde(default, rename = "silent")] _silent: bool, + #[serde(default, rename = "confirm_exit")] + _confirm_exit: bool, #[serde(default, rename = "pager")] _pager: bool, } @@ -23,6 +25,7 @@ impl ProgramEntry { _args: Vec::new(), _fork: false, _silent: false, + _confirm_exit: false, _pager: false, } } @@ -70,6 +73,10 @@ impl ProgramEntry { self._silent } + pub fn get_confirm_exit(&self) -> bool { + self._confirm_exit + } + pub fn get_pager(&self) -> bool { self._pager } @@ -90,6 +97,7 @@ impl std::default::Default for ProgramEntry { _args: Vec::new(), _fork: false, _silent: false, + _confirm_exit: false, _pager: false, } } @@ -109,6 +117,9 @@ impl std::fmt::Display for ProgramEntry { if self.get_silent() { f.write_str("[silent]").unwrap(); } + if self.get_confirm_exit() { + f.write_str("[confirm-exit]").unwrap(); + } if self.get_pager() { f.write_str("[pager]").unwrap(); } diff --git a/src/util/process.rs b/src/util/process.rs index dd8433f..8321fcc 100644 --- a/src/util/process.rs +++ b/src/util/process.rs @@ -60,7 +60,7 @@ where if entry.get_pager() { println!("{}", termion::clear::All); - let pager_env = std::env::var("PAGER").unwrap_or_else(|_| String::from("less")); + let pager_env = std::env::var("PAGER").unwrap_or_else(|_| String::from("tail")); let pager_args: Vec<&str> = pager_env.split_whitespace().collect(); if let Some(child_stdout) = command @@ -74,9 +74,13 @@ where .stdin(child_stdout) .status()?; } + command.status()?; + } else { + let _ = command.status()?; + if entry.get_confirm_exit() { + wait_for_enter()?; + } } - command.status()?; - Ok(()) } |