Skip to content

Commit

Permalink
add back confirm_exit option
Browse files Browse the repository at this point in the history
 - pager seems a little buggy at the moment with long running processes
 or processes that have a lot of output
  • Loading branch information
kamiyaa committed Mar 29, 2024
1 parent 2493c9d commit a103c88
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions src/config/clean/mimetype/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -23,6 +25,7 @@ impl ProgramEntry {
_args: Vec::new(),
_fork: false,
_silent: false,
_confirm_exit: false,
_pager: false,
}
}
Expand Down Expand Up @@ -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
}
Expand All @@ -90,6 +97,7 @@ impl std::default::Default for ProgramEntry {
_args: Vec::new(),
_fork: false,
_silent: false,
_confirm_exit: false,
_pager: false,
}
}
Expand All @@ -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();
}
Expand Down
10 changes: 7 additions & 3 deletions src/util/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(())
}

Expand Down

0 comments on commit a103c88

Please sign in to comment.