pub struct ShellJs {
pub config: Config,
pub env: HashMap<String, String>,
/* private fields */
}Expand description
A portable Rust counterpart of the ShellJS command-call interface. Arguments are individual values; command calls never concatenate them as shell syntax. Unlike JavaScript ShellJS, cwd changes affect this session only.
Fields§
§config: ConfigSession configuration.
env: HashMap<String, String>Environment used by commands.
Implementations§
Source§impl ShellJs
impl ShellJs
Sourcepub fn error_code(&self) -> i32
pub fn error_code(&self) -> i32
Exit code of the last command.
Sourcepub async fn call(
&mut self,
command: &str,
args: &[&str],
) -> Result<CommandResult>
pub async fn call( &mut self, command: &str, args: &[&str], ) -> Result<CommandResult>
Run a supported ShellJS command. Unsupported command names return 127;
external programs use cmd (argv) or exec (explicit shell syntax).
Sourcepub async fn cat(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn cat(&mut self, args: &[&str]) -> Result<CommandResult>
Run cat with separate argument values.
Sourcepub async fn chmod(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn chmod(&mut self, args: &[&str]) -> Result<CommandResult>
Run chmod with separate argument values.
Sourcepub async fn cp(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn cp(&mut self, args: &[&str]) -> Result<CommandResult>
Run cp with separate argument values.
Sourcepub async fn echo(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn echo(&mut self, args: &[&str]) -> Result<CommandResult>
Run echo with separate argument values.
Sourcepub async fn find(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn find(&mut self, args: &[&str]) -> Result<CommandResult>
Run find with separate argument values.
Sourcepub async fn grep(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn grep(&mut self, args: &[&str]) -> Result<CommandResult>
Run grep with separate argument values.
Sourcepub async fn head(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn head(&mut self, args: &[&str]) -> Result<CommandResult>
Run head with separate argument values.
Sourcepub async fn ln(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn ln(&mut self, args: &[&str]) -> Result<CommandResult>
Run ln with separate argument values.
Sourcepub async fn ls(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn ls(&mut self, args: &[&str]) -> Result<CommandResult>
Run ls with separate argument values.
Sourcepub async fn mkdir(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn mkdir(&mut self, args: &[&str]) -> Result<CommandResult>
Run mkdir with separate argument values.
Sourcepub async fn mv(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn mv(&mut self, args: &[&str]) -> Result<CommandResult>
Run mv with separate argument values.
Sourcepub async fn pwd(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn pwd(&mut self, args: &[&str]) -> Result<CommandResult>
Run pwd with separate argument values.
Sourcepub async fn rm(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn rm(&mut self, args: &[&str]) -> Result<CommandResult>
Run rm with separate argument values.
Sourcepub async fn sed(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn sed(&mut self, args: &[&str]) -> Result<CommandResult>
Run sed with separate argument values.
Sourcepub async fn sort(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn sort(&mut self, args: &[&str]) -> Result<CommandResult>
Run sort with separate argument values.
Sourcepub async fn tail(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn tail(&mut self, args: &[&str]) -> Result<CommandResult>
Run tail with separate argument values.
Sourcepub async fn touch(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn touch(&mut self, args: &[&str]) -> Result<CommandResult>
Run touch with separate argument values.
Sourcepub async fn uniq(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn uniq(&mut self, args: &[&str]) -> Result<CommandResult>
Run uniq with separate argument values.
Sourcepub async fn which(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn which(&mut self, args: &[&str]) -> Result<CommandResult>
Run which with separate argument values.
Sourcepub async fn basename(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn basename(&mut self, args: &[&str]) -> Result<CommandResult>
Run basename with separate argument values.
Sourcepub async fn dirname(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn dirname(&mut self, args: &[&str]) -> Result<CommandResult>
Run dirname with separate argument values.
Sourcepub async fn sleep(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn sleep(&mut self, args: &[&str]) -> Result<CommandResult>
Run sleep with separate argument values.
Sourcepub async fn env(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn env(&mut self, args: &[&str]) -> Result<CommandResult>
Run env with separate argument values.
Sourcepub async fn seq(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn seq(&mut self, args: &[&str]) -> Result<CommandResult>
Run seq with separate argument values.
Sourcepub async fn tee(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn tee(&mut self, args: &[&str]) -> Result<CommandResult>
Run tee with separate argument values.
Sourcepub async fn cd(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn cd(&mut self, args: &[&str]) -> Result<CommandResult>
Change this session’s directory without changing the host process cwd.
Sourcepub async fn test(&mut self, args: &[&str]) -> Result<bool>
pub async fn test(&mut self, args: &[&str]) -> Result<bool>
Evaluate a file test, returning a boolean.
Sourcepub async fn cmd(
&mut self,
program: &str,
args: &[&str],
) -> Result<CommandResult>
pub async fn cmd( &mut self, program: &str, args: &[&str], ) -> Result<CommandResult>
Execute a program with exact arguments, bypassing the shell.
Sourcepub async fn exec(&mut self, command: &str) -> Result<CommandResult>
pub async fn exec(&mut self, command: &str) -> Result<CommandResult>
Execute an explicitly supplied shell command.
Sourcepub fn dirs(&self) -> CommandResult
pub fn dirs(&self) -> CommandResult
List the current directory followed by the saved directory stack.
Sourcepub async fn pushd(&mut self, args: &[&str]) -> Result<CommandResult>
pub async fn pushd(&mut self, args: &[&str]) -> Result<CommandResult>
Save the current directory and change to the provided directory.
Sourcepub async fn popd(&mut self) -> Result<CommandResult>
pub async fn popd(&mut self) -> Result<CommandResult>
Restore the most recently saved directory.
Sourcepub fn set(&mut self, option: &str) -> Result<CommandResult>
pub fn set(&mut self, option: &str) -> Result<CommandResult>
Set fatal (-e/+e), verbose (-v/+v) or glob (-f/+f) modes.
Sourcepub async fn to(
&mut self,
result: &CommandResult,
path: &str,
append: bool,
) -> Result<CommandResult>
pub async fn to( &mut self, result: &CommandResult, path: &str, append: bool, ) -> Result<CommandResult>
Write captured stdout to a file (append=true corresponds to toEnd).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ShellJs
impl RefUnwindSafe for ShellJs
impl Send for ShellJs
impl Sync for ShellJs
impl Unpin for ShellJs
impl UnsafeUnpin for ShellJs
impl UnwindSafe for ShellJs
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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