diff --git a/src/main.rs b/src/main.rs index c694766..1f56fa6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,15 @@ use std::io::{self, prelude::*}; fn main() -> Result<(), io::Error> { + // TODO: check if stdin is empty and show usage let mut tty = std::fs::File::options() .write(true) .read(false) - .open("/dev/tty")?; - io::copy(&mut io::stdin(), &mut tty)?; - tty.flush()?; - io::copy(&mut io::stdin(), &mut io::stdout())?; + .open("/dev/tty") + .inspect_err(|err| eprintln!("{err}"))?; + // FIXME: only works with cargo run? + io::copy(&mut io::stdin(), &mut tty).inspect_err(|err| eprintln!("{err}"))?; + tty.flush().inspect_err(|err| eprintln!("{err}"))?; + io::copy(&mut io::stdin(), &mut io::stdout()).inspect_err(|err| eprintln!("{err}"))?; Ok(()) } diff --git a/tests/cli.rs b/tests/cli.rs new file mode 100644 index 0000000..6671249 --- /dev/null +++ b/tests/cli.rs @@ -0,0 +1,4 @@ +#[test] +fn pipe_echo_cat() { + todo!() +}