Ignore broken pipe error when printing dictionary
All checks were successful
lint/clippy Checking for common mistakes and opportunities for code improvement
build/msvc Build for the target platform: msvc
build/linux Build for the target platform: linux

stdout closing prematurely is normal behaviour, e.g. piping into `head`.
This commit is contained in:
Lucas Schwiderski 2025-04-22 00:05:29 +02:00
parent ddc69112bc
commit 72ab8811c3
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8

View file

@ -227,9 +227,12 @@ pub(crate) async fn run(mut ctx: sdk::Context, matches: &ArgMatches) -> Result<(
let lookup = &ctx.lookup;
let rows: Vec<_> = lookup.entries().iter().map(TableRow::from).collect();
print_stdout(rows.with_title())?;
Ok(())
match print_stdout(rows.with_title()) {
Ok(_) => Ok(()),
// Closing stdout prematurely is normal behavior with things like piping into `head`
Err(err) if err.kind() == std::io::ErrorKind::BrokenPipe => Ok(()),
Err(err) => Err(err.into()),
}
}
_ => unreachable!(
"clap is configured to require a subcommand, and they're all handled above"