Skip to main content

write_raw

Function write_raw 

Source
pub fn write_raw(text: &str, selector: OutputTo) -> Result<()>
Expand description

Write a raw document to the process stream selector names.

Not everything a CLI emits is an event. --docs renders a Markdown reference, --output plain help renders a human catalog, and shell bash renders a sourceable script: the consumer is > or source, so wrapping them in a protocol envelope would mean tool --docs > cli.md wrote JSON. Every CLI compiled from a registry inherits those outcomes, so something must write bytes to a process stream — and this is that one place. Without it each CLI hand-rolls the same dispatch, and they drift: this crate’s own binary treats a broken pipe as success while other tools returned a failure exit code for it.

A broken pipe is success. tool --docs | head closes the reader early, and reading the first page of a document is not a failure to report.

Split writes to stdout: a document is the result, not a diagnostic.