pub struct CommandRunner { /* private fields */ }Expand description
Command runner for executing commands with lifecycle management.
Implementations§
Source§impl CommandRunner
impl CommandRunner
Sourcepub fn new(ctx: CliContext) -> Self
pub fn new(ctx: CliContext) -> Self
Create a new command runner.
Sourcepub fn add_hook(&mut self, hook: impl CommandHook + 'static)
pub fn add_hook(&mut self, hook: impl CommandHook + 'static)
Add a command hook.
Sourcepub async fn run(&self, cmd: &dyn Command) -> CliResult<CommandOutput>
pub async fn run(&self, cmd: &dyn Command) -> CliResult<CommandOutput>
Run a command.
Sourcepub async fn run_with_shutdown<C: Command>(
&self,
cmd: &C,
) -> CliResult<CommandOutput>
pub async fn run_with_shutdown<C: Command>( &self, cmd: &C, ) -> CliResult<CommandOutput>
Run a command with graceful shutdown support.
Handles both Ctrl+C (SIGINT) and Ctrl+Z (SIGTSTP) signals. Ctrl+Z triggers a graceful shutdown instead of suspending the process, which prevents the zombie-port scenario where a suspended process holds a port but never processes incoming data.
Sourcepub fn context(&self) -> Arc<RwLock<CliContext>>
pub fn context(&self) -> Arc<RwLock<CliContext>>
Get the context.
Auto Trait Implementations§
impl Freeze for CommandRunner
impl !RefUnwindSafe for CommandRunner
impl Send for CommandRunner
impl Sync for CommandRunner
impl Unpin for CommandRunner
impl UnsafeUnpin for CommandRunner
impl !UnwindSafe for CommandRunner
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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