radicle-heartwood-lfs/crates/radicle-cli/src
Fintan Halpenny 1a31a9f541 cli: Handle broken pipe (SIGPIPE) gracefully
Prevent `rad` from panicking when its stdout is a closed pipe, e.g.
when running `rad config | head`.

The broken pipes are handled at the output boundaries using three
layers of defence:

1. Inner: Route all stdout output through `term::print()` and
   `term::print_inline()`, which use explicit `writeln!`/`write!` to
   a locked stdout and silently ignore write errors. All `println!`
   calls in `radicle-cli` and `radicle-term` are converted.
2. Middle: Catch `BrokenPipe` errors that propagate up via `anyhow`
   from subcommands in `main::run()`, and exit cleanly with code 0.
3. Outer: Install a panic hook that intercepts `println!` panics
   containing "Broken pipe" (from dependencies like clap) and exits
   cleanly, chained in front of human_panic's hook.

To prevent regressions, `#![deny(clippy::print_stdout)]` is added to
`radicle-cli`, requiring all future stdout output to go through the
safe `term::` functions.

Note: `eprintln!` calls (stderr) are not handled, as broken stderr
pipes are extremely rare in practice.
2026-04-29 10:57:24 +02:00
..
commands cli: Handle broken pipe (SIGPIPE) gracefully 2026-04-29 10:57:24 +02:00
git oid: `const ZERO_SHA1` instead of `fn sha1_zero` 2026-04-28 14:35:38 +02:00
terminal cli: Deduplicate RID Argument Handling 2026-04-17 17:09:15 +01:00
commands.rs cli/help: remove the help module 2025-11-01 11:20:43 +01:00
common_args.rs radicle: Teach `rad sync` and `rad clone` to accept feature levels 2026-03-24 15:07:18 +00:00
git.rs Spell "Radicle" with a captial R 2026-04-17 17:15:31 +01:00
lib.rs cli: Handle broken pipe (SIGPIPE) gracefully 2026-04-29 10:57:24 +02:00
main.rs cli: Handle broken pipe (SIGPIPE) gracefully 2026-04-29 10:57:24 +02:00
node.rs rust/edition/fmt: 2021 → 2024 2026-03-30 16:57:51 +02:00
pager.rs term, cli: `winsplit` over `shlex` on Windows 2026-02-11 10:26:22 +01:00
project.rs workspace/rust/clippy: Fix all warnings 2025-10-17 12:56:43 +02:00
terminal.rs Spell "Radicle" with a captial R 2026-04-17 17:15:31 +01:00
warning.rs cli: Update warning for new bootstrap node names 2026-04-27 18:20:25 +02:00