[][src]Macro procmd::cmd

cmd!() { /* proc-macro */ }

A macro for building commands.

Generating a simple command

To generate a std::process::Command, the program and additional arguments can be passed to the macro.

Example

The invocation:

let cmd = cmd!("ls", "-a", "/");

expands to:

let cmd = {
    let mut cmd = ::std::process::Command::new("ls");
    cmd.arg("-a");
    cmd.arg("/");
    cmd
};

Generating a piped command

To generate a PipeCommand, multiple programs and arguments seperated by => can be passed to the macro.

Example

The invocation:

let pipe_cmd = cmd!("ls" => "grep", "test" => "wc", "-l");

expands to:

let pipe_cmd = ::procmd::PipeCommand::new([
    {
        let mut cmd = ::std::process::Command::new("ls");
        cmd
    },
    {
        let mut cmd = ::std::process::Command::new("grep");
        cmd.arg("test");
        cmd
    },
    {
        let mut cmd = ::std::process::Command::new("wc");
        cmd.arg("-l");
        cmd
    },
]);