Skip to main content

Cx

Struct Cx 

Source
pub struct Cx {
    pub out: Stream,
    pub err: Stream,
    pub env: Env,
    pub cwd: PathBuf,
    pub git: Arc<dyn GitCli + Send + Sync>,
    pub gh: Arc<dyn GhClient + Send + Sync>,
    pub agent: Arc<dyn AgentClient + Send + Sync>,
    pub input: Box<dyn Input + Send>,
    pub color_flag: Option<ColorChoice>,
    pub no_pager: bool,
    pub verbose: u8,
}
Expand description

The runtime context threaded through command dispatch.

Fields§

§out: Stream

Standard output: navigation paths, JSON, and data-command results only.

§err: Stream

Standard error: all human-facing text, prompts, logs, and errors.

§env: Env

A snapshot of the process environment.

§cwd: PathBuf

The effective working directory (after any -C).

§git: Arc<dyn GitCli + Send + Sync>

The git subprocess handle (real, or a fake in tests). Shared via Arc so the TUI can clone it into async tasks.

§gh: Arc<dyn GhClient + Send + Sync>

The gh subprocess handle (real, or a fake in tests).

§agent: Arc<dyn AgentClient + Send + Sync>

The code-agent subprocess handle (real, or a fake in tests). Drives a code agent (e.g. claude) to draft PR content; see AgentClient.

§input: Box<dyn Input + Send>

Interactive input source for confirmation prompts.

§color_flag: Option<ColorChoice>

The --color flag value, if given (set during dispatch).

§no_pager: bool

The --no-pager flag (set during dispatch).

§verbose: u8

The -v/--verbose count: extra diagnostics to stderr (set during dispatch). 0 is the default (quiet).

Implementations§

Source§

impl Cx

Source

pub fn new( out: Stream, err: Stream, env: Env, cwd: PathBuf, git: Arc<dyn GitCli + Send + Sync>, gh: Arc<dyn GhClient + Send + Sync>, agent: Arc<dyn AgentClient + Send + Sync>, input: Box<dyn Input + Send>, ) -> Self

Builds a context from injected streams, environment, working dir, the git/gh/agent handles, and the input source. The global flag fields (color_flag, no_pager) default off and are set during dispatch.

Source

pub fn color_enabled(&self, ui_color: ColorChoice) -> bool

Resolves whether to emit color for stdout, given the resolved config’s ui.color (spec §11 precedence).

Source

pub fn color_enabled_err(&self, ui_color: ColorChoice) -> bool

Resolves whether to emit color for the TUI, which draws to the alternate screen on stderr. The precedence (--color, NO_COLOR, ui.color) is the same as Cx::color_enabled, but auto follows stderr’s TTY status rather than stdout’s (stdout is reserved for the chosen path and is usually piped, e.g. cd "$(wt)").

Auto Trait Implementations§

§

impl !RefUnwindSafe for Cx

§

impl !Sync for Cx

§

impl !UnwindSafe for Cx

§

impl Freeze for Cx

§

impl Send for Cx

§

impl Unpin for Cx

§

impl UnsafeUnpin for Cx

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more