removed stdout flag

Signed-off-by: aserowy <serowy@hotmail.com>
This commit is contained in:
aserowy 2024-01-08 08:30:11 +01:00
parent df2a5ee95c
commit 0e2893ef25
9 changed files with 19 additions and 37 deletions

18
flake.lock generated
View file

@ -5,11 +5,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
@ -20,11 +20,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1701174899,
"narHash": "sha256-1W+FMe8mWsJKXoBc+QgKmEeRj33kTFnPq7XCjU+bfnA=",
"lastModified": 1704161960,
"narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "010c7296f3b19a58b206fdf7d68d75a5b0a09e9e",
"rev": "63143ac2c9186be6d9da6035fa22620018c85932",
"type": "github"
},
"original": {
@ -51,11 +51,11 @@
]
},
"locked": {
"lastModified": 1701224160,
"narHash": "sha256-qnMmxNMKmd6Soel0cfauyMJ+LzuZbvmiDQPSIuTbQ+M=",
"lastModified": 1704507282,
"narHash": "sha256-PDfS8fj40mm2QWpbd/aiocgwcI/WHzqLKERRJkoEvXU=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "4a080e26d55eaedb95ab1bf8eeaeb84149c10f12",
"rev": "a127cccf7943beae944953963ba118d643299c3b",
"type": "github"
},
"original": {

View file

@ -5,6 +5,7 @@ pkgs.mkShell {
rustToolchain
rust-analyzer
nodejs_20
nodePackages.cspell
file

View file

@ -15,9 +15,6 @@ pub struct Args {
/// Write the selected files on open emitted by the chooser mode
#[arg(long)]
pub chooser_file: Option<PathBuf>,
/// Write the selected files on open to stdout
#[arg(long, action)]
pub chooser_stdout: bool,
/// Clear the cache directory
#[arg(long, action)]

View file

@ -107,10 +107,6 @@ impl Manager {
quit_actions.push(QuitAction::SelectToFile(paths.clone()));
};
if ARGS.chooser_stdout {
quit_actions.push(QuitAction::SelectToStdout(paths.clone()));
};
if quit_actions.len() > 1 {
tokio::spawn(async move {
emit!(Quit(quit_actions));

View file

@ -20,7 +20,7 @@ impl Select {
pub async fn _show(cfg: SelectCfg) -> Result<usize> {
let (tx, rx) = oneshot::channel();
emit!(Call(Exec::call("show", vec![]).with_data(Opt { cfg, tx }).vec(), Layer::Select));
rx.await.unwrap_or_else(|_| Term::goodbye(|| false, None))
rx.await.unwrap_or_else(|_| Term::goodbye(|| false))
}
pub fn show(&mut self, opt: impl TryInto<Opt>) {

View file

@ -9,22 +9,18 @@ use crate::app::App;
impl App {
pub(crate) fn quit(&mut self, quit_actions: Vec<QuitAction>) -> Result<()> {
if quit_actions.contains(&QuitAction::None) {
Term::goodbye(|| false, None)
Term::goodbye(|| false)
}
let mut stdout = None;
for quit_action in quit_actions {
match quit_action {
QuitAction::None => unreachable!(),
QuitAction::CwdToFile => self.cwd_to_file(),
QuitAction::SelectToFile(selected) => self.select_to_file(selected),
QuitAction::SelectToStdout(selected) => {
stdout = Some(selected.as_encoded_bytes().to_owned())
}
}
}
Term::goodbye(|| false, stdout.as_deref());
Term::goodbye(|| false);
}
fn cwd_to_file(&self) {

View file

@ -8,13 +8,10 @@ impl Panic {
let hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |info| {
Term::goodbye(
|| {
hook(info);
true
},
None,
);
Term::goodbye(|| {
hook(info);
true
});
}));
}
}

View file

@ -23,7 +23,6 @@ pub enum QuitAction {
None,
CwdToFile,
SelectToFile(OsString),
SelectToStdout(OsString),
}
impl Event {
@ -35,7 +34,7 @@ impl Event {
pub async fn wait<T>(self, rx: oneshot::Receiver<T>) -> T {
TX.send(self).ok();
rx.await.unwrap_or_else(|_| Term::goodbye(|| false, None))
rx.await.unwrap_or_else(|_| Term::goodbye(|| false))
}
}

View file

@ -49,7 +49,7 @@ impl Term {
Ok(disable_raw_mode()?)
}
pub fn goodbye(f: impl FnOnce() -> bool, last_words: Option<&[u8]>) -> ! {
pub fn goodbye(f: impl FnOnce() -> bool) -> ! {
execute!(
stdout(),
PopKeyboardEnhancementFlags,
@ -63,10 +63,6 @@ impl Term {
disable_raw_mode().ok();
if let Some(words) = last_words {
std::io::stdout().write_all(words).ok();
}
std::process::exit(f() as i32);
}