diff --git a/src/main.rs b/src/main.rs index 5ac7301..6fd6a66 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use std::{ collections::HashSet, env, fs::File, - io::{stderr, stdin, stdout, BufReader, Read, Write}, + io::{stderr, stdin, stdout, BufReader, IsTerminal, Read, Write}, num::NonZeroUsize, path::PathBuf, process, @@ -97,6 +97,8 @@ fn main() -> anyhow::Result<()> { .exit() } + warn_if_stdin_is_tty(); + let pid = process::id(); let span = info_span!("", pid); let _handle = span.enter(); @@ -174,6 +176,8 @@ fn main() -> anyhow::Result<()> { Cmd::Simplify { lang } => { use om_wikiparser::html; + warn_if_stdin_is_tty(); + let mut input = String::new(); stdin().read_to_string(&mut input)?; @@ -261,6 +265,12 @@ fn get_thread_count(requested: Option) -> anyhow::Result { Ok(procs) } +fn warn_if_stdin_is_tty() { + if stdin().is_terminal() { + warn!("Expecting input on stdin but it is a TTY"); + } +} + /// Get the version returned by `git describe`, e.g.: /// - `v2.0` if a git tag /// - the commit hash `034ac04` if not a tag