pub struct RobCommand {
pub cfg: Config,
/* private fields */
}Expand description
Structure for executing commands (actually just keeping them, but it’s just for now)
Fields§
§cfg: ConfigImplementations§
Source§impl RobCommand
impl RobCommand
pub fn new() -> RobCommand
Sourcepub fn append<S>(&mut self, xs: &[S]) -> &mut Self
pub fn append<S>(&mut self, xs: &[S]) -> &mut Self
Appends arguments to the last line in cmd,
let p = pathbuf!["dummy", "rakivo", "dummy.cpp"];
Rob::new()
.append(&["clang++", "-o", "output", p.to_str().unwrap()])
.execute()It Outputs:
[CMD] clang++ -o output test/test1/test.cppSourcepub fn append_mv<S>(&mut self, xs: &[S]) -> &mut Self
pub fn append_mv<S>(&mut self, xs: &[S]) -> &mut Self
Performs append and moves append ptr forward
pub fn move_acp_ptr(&mut self) -> &mut Self
pub fn execute(&mut self) -> IoResult<&mut Self>
pub fn execute_sync(&mut self) -> IoResult<Output>
pub fn execute_sync_dont_exit(&mut self) -> IoResult<Output>
pub fn execute_all_sync(&mut self) -> RobResult<Vec<Output>>
pub fn execute_all_sync_dont_exit(&mut self) -> RobResult<Vec<Output>>
Sourcepub fn execute_all_sync_exit(&mut self, exit_: bool) -> RobResult<Vec<Output>>
pub fn execute_all_sync_exit(&mut self, exit_: bool) -> RobResult<Vec<Output>>
Returns vector of child which you can turn into vector of the outputs using Rob::wait_for_children.
Sourcepub fn output(&mut self) -> Option<Output>
pub fn output(&mut self) -> Option<Output>
Function for receiving output of the last executed command.
let mut rob = Rob::new();
rob
.append(&["echo hello"])
.execute()?
.append(&[CC, "-o build/output", "./test/main.c"])
.execute()?
.append(&[CXXC, "-o build/outputpp", "./test/main.cpp"])
.execute()?
.append(&["echo byebye"])
.execute()?;
while let Some(out) = rob.output() {
println!("{out:?}");
}Will print:
[CMD] echo hello
[INFO] hello
[CMD] clang -o build/output ./test/main.c
[CMD] clang++ -o build/outputpp ./test/main.cpp
[CMD] echo byebye
[INFO] byebye
Output { status: ExitStatus(unix_wait_status(0)), stdout: "hello\n", stderr: "" }
Output { status: ExitStatus(unix_wait_status(0)), stdout: "", stderr: "" }
Output { status: ExitStatus(unix_wait_status(0)), stdout: "", stderr: "" }
Output { status: ExitStatus(unix_wait_status(0)), stdout: "byebye\n", stderr: "" }As you can see, you receiving outputs in the reversed order, i think this is the best way of doing that.
pub fn outputs_refs(&self) -> VecDeque<&Output>
pub fn outputs(self) -> VecDeque<Output>
Sourcepub fn execute_all_async(&mut self) -> RobResult<Vec<Child>>
pub fn execute_all_async(&mut self) -> RobResult<Vec<Child>>
Returns vector of child which you can turn into vector of the outputs using Rob::wait_for_children.
pub fn execute_all_async_and_wait(&mut self) -> RobResult<Vec<Output>>
pub fn execute_all_async_and_wait_dont_exit(&mut self) -> RobResult<Vec<Output>>
Sourcepub fn execute_all_async_and_wait_exit(
&mut self,
exit: bool,
) -> RobResult<Vec<Output>>
pub fn execute_all_async_and_wait_exit( &mut self, exit: bool, ) -> RobResult<Vec<Output>>
Returns vector of child which you can turn into vector of the outputs using Rob::wait_for_children.
Sourcepub fn wait_for_children_deq(
children: VecDeque<Child>,
cfg: &Config,
exit_: bool,
) -> RobResult<Vec<Output>>
pub fn wait_for_children_deq( children: VecDeque<Child>, cfg: &Config, exit_: bool, ) -> RobResult<Vec<Output>>
Blocks the main thread and waits for all of the children.
Sourcepub fn wait_for_child(child: Child) -> IoResult<Output>
pub fn wait_for_child(child: Child) -> IoResult<Output>
Blocks the main thread and waits for the child.
pub fn echo(&mut self, echo: bool) -> &mut Self
pub fn keepgoing(&mut self, keepgoing: bool) -> &mut Self
Trait Implementations§
Source§impl Clone for RobCommand
impl Clone for RobCommand
Source§fn clone(&self) -> RobCommand
fn clone(&self) -> RobCommand
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more