Skip to content

Commit a866fe1

Browse files
committed
cli: handle EPIPE for version subcommand
EPIPE handling was added recently via {e}println_nopipe() macros, but wasn't used for the "version" subcommand. This replaces println() calls with println_nopipe(). Before: ``` ➜ oxide.rs git:(main) ./target/debug/oxide version | head -1 Oxide CLI 0.6.1+20240710.0 ➜ oxide.rs git:(main) ./target/debug/oxide version | a zsh: command not found: a thread 'tokio-runtime-worker' panicked at library/std/src/io/stdio.rs:1021:9: failed printing to stdout: Broken pipe (os error 32) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread 'main' panicked at cli/src/main.rs:105:10: called `Result::unwrap()` on an `Err` value: JoinError::Panic(Id(9), ...) ➜ oxide.rs git:(main) ``` After: ``` ➜ oxide.rs git:(trey/epipe_version) ./target/debug/oxide version | head -1 Oxide CLI 0.6.1+20240710.0 ➜ oxide.rs git:(trey/epipe_version) ./target/debug/oxide version | a zsh: command not found: a ➜ oxide.rs git:(trey/epipe_version) ``` Signed-off-by: Trey Aspelund <[email protected]>
1 parent 9f35461 commit a866fe1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cli/src/cmd_version.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use async_trait::async_trait;
99
use clap::Parser;
1010
use oxide::Client;
1111

12+
use crate::println_nopipe;
1213
use crate::{context::Context, RunnableCmd};
1314

1415
pub mod built_info {
@@ -27,9 +28,9 @@ impl RunnableCmd for CmdVersion {
2728
let cli_version = built_info::PKG_VERSION;
2829
let api_version = Client::new("").api_version();
2930

30-
println!("Oxide CLI {}", cli_version);
31+
println_nopipe!("Oxide CLI {}", cli_version);
3132

32-
println!(
33+
println_nopipe!(
3334
"Built from commit: {} {}",
3435
built_info::GIT_COMMIT_HASH.unwrap(),
3536
if matches!(built_info::GIT_DIRTY, Some(true)) {
@@ -39,7 +40,7 @@ impl RunnableCmd for CmdVersion {
3940
}
4041
);
4142

42-
println!("Oxide API: {}", api_version);
43+
println_nopipe!("Oxide API: {}", api_version);
4344

4445
Ok(())
4546
}

0 commit comments

Comments
 (0)