From a93a642765540d4010dc2fab90737cd39abaa32d Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 9 Jun 2021 16:45:23 +0800 Subject: Show TUI on stderr to enable writing files to stdout --- src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0596458..15a34ff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -73,12 +73,12 @@ fn main() -> Result<()> { use crosstermion::terminal::{tui::new_terminal, AlternateRawScreen}; let no_tty_msg = "Interactive mode requires a connected terminal"; - if atty::isnt(atty::Stream::Stdout) { + if atty::isnt(atty::Stream::Stderr) { return Err(anyhow!(no_tty_msg)); } let mut terminal = new_terminal( - AlternateRawScreen::try_from(io::stdout()).with_context(|| no_tty_msg)?, + AlternateRawScreen::try_from(io::stderr()).with_context(|| no_tty_msg)?, ) .with_context(|| "Could not instantiate terminal")?; let res = TerminalApp::initialize( @@ -106,7 +106,7 @@ fn main() -> Result<()> { }); drop(terminal); - io::stdout().flush().ok(); + io::stderr().flush().ok(); // Exit 'quickly' to avoid having to not have to deal with slightly different types in the other match branches std::process::exit( -- cgit v1.2.3