Struct robuild::RobCommand
source · 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>
sourcepub fn execute_all_sync(&mut self) -> IoResult<Vec<Output>>
pub fn execute_all_sync(&mut self) -> IoResult<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) -> IoResult<Vec<Child>>
pub fn execute_all_async(&mut self) -> IoResult<Vec<Child>>
Returns vector of child which you can turn into vector of the outputs using Rob::wait_for_children.
sourcepub fn execute_all_async_and_wait(&mut self) -> IoResult<Vec<Output>>
pub fn execute_all_async_and_wait(&mut self) -> IoResult<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,
) -> IoResult<Vec<Output>>
pub fn wait_for_children_deq( children: VecDeque<Child>, cfg: &Config, ) -> IoResult<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 moresource§impl Debug for RobCommand
impl Debug for RobCommand
source§impl Default for RobCommand
impl Default for RobCommand
source§impl From<Config> for RobCommand
impl From<Config> for RobCommand
source§impl Hash for RobCommand
impl Hash for RobCommand
source§impl PartialEq for RobCommand
impl PartialEq for RobCommand
source§fn eq(&self, other: &RobCommand) -> bool
fn eq(&self, other: &RobCommand) -> bool
self and other values to be equal, and is used
by ==.