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>,
/* private fields */
}Expand description
Represents a simple command to be executed.
Fields§
§params: ExecutionParametersThe execution parameters for the command.
command_name: StringThe name of the command to execute.
args: Vec<CommandArg>The arguments to the command, including the command itself.
use_functions: boolWhether 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.
Implementations§
Source§impl<'a, SE: ShellExtensions> SimpleCommand<'a, SE>
impl<'a, SE: ShellExtensions> SimpleCommand<'a, SE>
Sourcepub fn new<I>(
shell: ShellForCommand<'a, SE>,
params: ExecutionParameters,
command_name: String,
args: I,
) -> Selfwhere
I: IntoIterator<Item = CommandArg>,
pub fn new<I>(
shell: ShellForCommand<'a, SE>,
params: ExecutionParameters,
command_name: String,
args: I,
) -> Selfwhere
I: IntoIterator<Item = CommandArg>,
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.
Sourcepub async fn execute(self) -> Result<ExecutionSpawnResult, Error>
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.
§Errors
ErrorKind::CommandNotFoundif the name is not a builtin or function and is not found in the search path.- Any error from starting a builtin, function, or external process; for
example
ErrorKind::FailedToExecuteCommandorErrorKind::WorkingDirMissingwhen an external command cannot be spawned.
§Panics
Does not panic in practice: the unwrap runs only after the builtin
lookup was checked to be Some.
Auto Trait Implementations§
impl<'a, SE> !RefUnwindSafe for SimpleCommand<'a, SE>
impl<'a, SE> !UnwindSafe for SimpleCommand<'a, SE>
impl<'a, SE> Freeze for SimpleCommand<'a, SE>where
ShellForCommand<'a, SE>: Freeze,
impl<'a, SE> Send for SimpleCommand<'a, SE>where
ShellForCommand<'a, SE>: Send,
impl<'a, SE> Sync for SimpleCommand<'a, SE>where
ShellForCommand<'a, SE>: Sync,
impl<'a, SE> Unpin for SimpleCommand<'a, SE>where
ShellForCommand<'a, SE>: Unpin,
impl<'a, SE> UnsafeUnpin for SimpleCommand<'a, SE>where
ShellForCommand<'a, SE>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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