Expand description
§Public API
CliOutput is the parameterized output abstraction every cmd_*
handler writes to. It owns mutable references to dyn Write for
both stdout and stderr so production code can pass io::stdout() /
io::stderr() locks while unit tests pass Vec<u8> capture buffers.
The struct is the stable contract between W5a (this module) and the downstream cmd_* migrations in W5b/c/d. Do not change the field visibility or method signatures without coordinating across closers.
§Stable surface
ⓘ
pub struct CliOutput<'a> {
pub stdout: &'a mut dyn Write,
pub stderr: &'a mut dyn Write,
}
impl<'a> CliOutput<'a> {
pub fn from_std(stdout: &'a mut dyn Write, stderr: &'a mut dyn Write) -> Self;
}§Usage in handlers
Every cmd_* replaces println!(...) with writeln!(out.stdout, ...)?
and eprintln!(...) with writeln!(out.stderr, ...)?. The ?
propagates I/O errors instead of panicking on broken-pipe (closing
a long-running pager mid-output, etc.).
Structs§
- CliOutput
- Output abstraction passed to every CLI command. Carries mutable
references to stdout and stderr writers so handlers can be unit-tested
by capturing into
Vec<u8>buffers.