RobCommand

Struct 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: Config

Implementations§

Source§

impl RobCommand

Source

pub fn new() -> RobCommand

Source

pub fn append<S>(&mut self, xs: &[S]) -> &mut Self
where S: ToString + PartialEq<&'static str>,

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.cpp
Source

pub fn append_mv<S>(&mut self, xs: &[S]) -> &mut Self
where S: ToString + PartialEq<&'static str>,

Performs append and moves append ptr forward

Source

pub fn move_acp_ptr(&mut self) -> &mut Self

Source

pub fn execute(&mut self) -> IoResult<&mut Self>

Source

pub fn execute_sync(&mut self) -> IoResult<Output>

Source

pub fn execute_sync_dont_exit(&mut self) -> IoResult<Output>

Source

pub fn execute_all_sync(&mut self) -> RobResult<Vec<Output>>

Source

pub fn execute_all_sync_dont_exit(&mut self) -> RobResult<Vec<Output>>

Source

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.

Source

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.

Source

pub fn outputs_refs(&self) -> VecDeque<&Output>

Source

pub fn outputs(self) -> VecDeque<Output>

Source

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.

Source

pub fn execute_all_async_and_wait(&mut self) -> RobResult<Vec<Output>>

Source

pub fn execute_all_async_and_wait_dont_exit(&mut self) -> RobResult<Vec<Output>>

Source

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.

Source

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.

Source

pub fn wait_for_child(child: Child) -> IoResult<Output>

Blocks the main thread and waits for the child.

Source

pub fn echo(&mut self, echo: bool) -> &mut Self

Source

pub fn keepgoing(&mut self, keepgoing: bool) -> &mut Self

Trait Implementations§

Source§

impl Clone for RobCommand

Source§

fn clone(&self) -> RobCommand

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RobCommand

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RobCommand

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<Config> for RobCommand

Source§

fn from(cfg: Config) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Vec<String>>> for RobCommand

Source§

fn from(lines: Vec<Vec<String>>) -> Self

Converts to this type from the input type.
Source§

impl Hash for RobCommand

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for RobCommand

Source§

fn eq(&self, other: &RobCommand) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for RobCommand

Source§

impl StructuralPartialEq for RobCommand

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.