Skip to main content

SimpleCommand

Struct SimpleCommand 

Source
pub struct SimpleCommand<'a, SE: ShellExtensions> {
    pub params: ExecutionParameters,
    pub command_name: String,
    pub args: Vec<CommandArg>,
    pub use_functions: bool,
    pub path_dirs: Option<Vec<PathBuf>>,
    pub process_group_id: Option<i32>,
    pub argv0: Option<String>,
    pub post_execute: Option<fn(&mut Shell<SE>) -> Result<(), Error>>,
    /* private fields */
}
Expand description

Represents a simple command to be executed.

Fields§

§params: ExecutionParameters

The execution parameters for the command.

§command_name: String

The name of the command to execute.

§args: Vec<CommandArg>

The arguments to the command, including the command itself.

§use_functions: bool

Whether to consider shell functions when looking up the command name. If true, shell functions will be checked; if false, they will be ignored.

§path_dirs: Option<Vec<PathBuf>>

Optional list of directories to search for external commands. If left None, the default search logic will be used.

§process_group_id: Option<i32>

The process group ID to use for externally executed commands. This may be None, in which case the default behavior will be used.

§argv0: Option<String>

Optional override for the argv[0] value presented to an externally spawned process. When None, command_name is used.

§post_execute: Option<fn(&mut Shell<SE>) -> Result<(), Error>>

Optionally provides a function that can run after execution occurs. Note that it is not invoked if the shell is discarded during the execution process.

Implementations§

Source§

impl<'a, SE: ShellExtensions> SimpleCommand<'a, SE>

Source

pub const fn new( shell: ShellForCommand<'a, SE>, params: ExecutionParameters, command_name: String, args: Vec<CommandArg>, ) -> Self

Creates a new SimpleCommand instance.

§Arguments
  • shell - The shell in which to execute the command.
  • params - The execution parameters for the command.
  • command_name - The name of the command to execute.
  • args - The arguments to the command, including the command itself.
Source

pub async fn execute(self) -> Result<ExecutionSpawnResult, Error>

Executes the simple command.

The command may be a builtin, a shell function, or an externally executed command. This function’s implementation is responsible for dispatching it appropriately according to the context provided.

Auto Trait Implementations§

§

impl<'a, SE> Freeze for SimpleCommand<'a, SE>

§

impl<'a, SE> !RefUnwindSafe for SimpleCommand<'a, SE>

§

impl<'a, SE> Send for SimpleCommand<'a, SE>

§

impl<'a, SE> Sync for SimpleCommand<'a, SE>

§

impl<'a, SE> Unpin for SimpleCommand<'a, SE>

§

impl<'a, SE> UnsafeUnpin for SimpleCommand<'a, SE>

§

impl<'a, SE> !UnwindSafe for SimpleCommand<'a, SE>

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, 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