pub enum OutputContext {
Hook,
Machine,
Interactive,
Colored,
Plain,
}Expand description
Output context determines what level of rich formatting to use.
RCH operates in multiple contexts with vastly different output requirements:
| Context | Rich OK? | Why |
|---|---|---|
| Hook mode | NO | Agent reads JSON from stdout |
| Interactive | YES | Human at terminal |
| Piped output | MAYBE | Depends on FORCE_COLOR |
| Daemon service | NO | No terminal, logs only |
| Worker execute | NO | Output goes to agent |
Variants§
Hook
Hook mode - JSON protocol only, ZERO decoration. Detected when: JSON on stdin, or called as hook subprocess.
Machine
Machine-readable output explicitly requested. Detected when: –json flag, RCH_JSON=1, –format=json.
Interactive
Interactive terminal session. Detected when: stderr is TTY, not hook mode.
Colored
Colored output but no full rich (no tables/panels). Detected when: FORCE_COLOR set but no TTY.
Plain
Plain text only, no ANSI codes. Detected when: NO_COLOR set, or no TTY and no FORCE_COLOR.
Implementations§
Source§impl OutputContext
impl OutputContext
Sourcepub fn detect() -> Self
pub fn detect() -> Self
Detect the current output context automatically.
Detection order (first match wins):
- RCH_JSON=1 -> Machine
- Hook invocation detection -> Hook
- NO_COLOR set -> Plain
- FORCE_COLOR=0 -> Plain
- stderr is TTY -> Interactive
- FORCE_COLOR set -> Colored
- Default -> Plain
Sourcepub const fn plain() -> Self
pub const fn plain() -> Self
Create a context that explicitly uses plain text (no colors/formatting).
Sourcepub const fn interactive() -> Self
pub const fn interactive() -> Self
Create a context that explicitly uses interactive mode.
Sourcepub const fn supports_rich(&self) -> bool
pub const fn supports_rich(&self) -> bool
Can we use full rich output (tables, panels, etc)?
Sourcepub const fn supports_color(&self) -> bool
pub const fn supports_color(&self) -> bool
Can we use ANSI color codes?
Sourcepub const fn is_machine(&self) -> bool
pub const fn is_machine(&self) -> bool
Is this machine-readable output mode?
Sourcepub const fn is_decorated(&self) -> bool
pub const fn is_decorated(&self) -> bool
Should we output ANYTHING decorative?
Sourcepub fn supports_unicode(&self) -> bool
pub fn supports_unicode(&self) -> bool
Can we use Unicode characters (box drawing, etc)?
Checks locale environment variables for UTF-8 support.
Trait Implementations§
Source§impl Clone for OutputContext
impl Clone for OutputContext
Source§fn clone(&self) -> OutputContext
fn clone(&self) -> OutputContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OutputContext
impl Debug for OutputContext
Source§impl Default for OutputContext
impl Default for OutputContext
Source§impl Display for OutputContext
impl Display for OutputContext
Source§impl PartialEq for OutputContext
impl PartialEq for OutputContext
Source§fn eq(&self, other: &OutputContext) -> bool
fn eq(&self, other: &OutputContext) -> bool
self and other values to be equal, and is used by ==.impl Copy for OutputContext
impl Eq for OutputContext
impl StructuralPartialEq for OutputContext
Auto Trait Implementations§
impl Freeze for OutputContext
impl RefUnwindSafe for OutputContext
impl Send for OutputContext
impl Sync for OutputContext
impl Unpin for OutputContext
impl UnsafeUnpin for OutputContext
impl UnwindSafe for OutputContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.