Struct super_process::sh::ShellScript
source · pub struct ShellScript {
pub script_path: Exe,
}Expand description
Execute a command line beginning with this shell script.
The later arguments provided via Self::with_command (FIXME!)
use std::io::Write;
use tempfile::NamedTempFile;
use super_process::{sh, exe, sync::SyncInvocable, base::CommandBase, fs};
let script_path = {
let (mut script_file, script_path) = NamedTempFile::new().unwrap().into_parts();
script_file.write_all(b"echo hey\n").unwrap();
script_file.sync_all().unwrap();
script_path.keep().unwrap()
};
let script_path = exe::Exe(fs::File(script_path));
let script = sh::ShellScript { script_path };
let command = script.with_command(exe::Command::default())
.setup_command().await.unwrap();
let output = command.invoke().await.expect("script should succeed");
assert!(b"hey\n".as_ref() == &output.stdout);Fields§
§script_path: ExeThe script to execute.
Implementations§
source§impl ShellScript
impl ShellScript
sourcepub fn with_command(self, base: Command) -> ShellScriptInvocation
pub fn with_command(self, base: Command) -> ShellScriptInvocation
Provide a command line for this shell script to execute.
Trait Implementations§
source§impl Clone for ShellScript
impl Clone for ShellScript
source§fn clone(&self) -> ShellScript
fn clone(&self) -> ShellScript
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl RefUnwindSafe for ShellScript
impl Send for ShellScript
impl Sync for ShellScript
impl Unpin for ShellScript
impl UnwindSafe for ShellScript
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