pub struct TerminalPresenter { /* private fields */ }Expand description
Terminal presenter adapter
Renders command output to the terminal. In text mode, all output goes to stdout. In JSON
mode, messages go to stderr and artifacts are serialized as JSON to stdout. This follows the
convention used by gh, kubectl, and jq.
The presenter also asks the user the questions of the command. It writes a question to stderr in both modes, and the user answers with one line on stdin. Verbosity and output mode do not suppress a question. A presenter that is not built as interactive drops every question.
TerminalPresenter is constructed once via its builder, consumed by a single call to
present, and dropped when the command completes. The presenter holds the EventReceiver
alive during command execution so that EventSenders do not receive errors when sending.
After the command completes, the presenter and its receiver are dropped.
§Examples
use clawless_core::event::event_channel;
use clawless_cli::presenter::TerminalPresenter;
let (_sender, receiver) = event_channel();
let presenter = TerminalPresenter::builder().receiver(receiver).build();Implementations§
Source§impl TerminalPresenter
impl TerminalPresenter
Sourcepub fn builder() -> TerminalPresenterBuilder
pub fn builder() -> TerminalPresenterBuilder
Create an instance of TerminalPresenter using the builder syntax