Skip to main content

TerminalPresenter

Struct TerminalPresenter 

Source
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.

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

Source

pub fn builder() -> TerminalPresenterBuilder

Create an instance of TerminalPresenter using the builder syntax

Trait Implementations§

Source§

impl Debug for TerminalPresenter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Presenter for TerminalPresenter

Source§

fn present<'async_trait>( self, command: Pin<Box<dyn Future<Output = CommandResult> + Send>>, ) -> Pin<Box<dyn Future<Output = CommandResult> + 'async_trait>>
where Self: 'async_trait,

Presents the output of a command Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.