runcmd

Crates.ioruncmd
lib.rsruncmd
version0.1.1
sourcesrc
created_at2022-12-20 08:00:29.58927
updated_at2022-12-20 09:36:29.858449
descriptionThis library is used for extending `Execute` which is extending `Command` in order to execute commands more easily. Especially made for simple shell commands returning an exit code as a number, stdout and stderr as strings.
homepage
repositoryhttps://github.com/jaredeh/runcmd
max_upload_size
id742116
size9,523
(jaredeh)

documentation

README

RunCmd

CI

This library is used for extending Execute which is extending Command in order to execute commands more easily. Especially made for simple shell commands returning an exit code as a number, stdout and stderr as strings.

Usage

use std::process::Command;

use runcmd::RunCmd;

RunCmd::new("echo \"Hello World\"").execute();

verbose

verbose() will print the ins and outs to stdout

RunCmd::new("echo \"Hello World\"")
    .verbose()
    .execute();

shell

shell() sets the executor to run the command in a shell using the underlying Execute::shell rather than Execute::command.

RunCmd::new("echo \"Hello World\"")
    .shell()
    .execute();

executep

executep() runs the command, without returning anything, but panics if the command doesn't succeed. Useful in only the most trival circumstances.

RunCmd::new("echo \"Hello World\"")
    .shell()
    .executep();

execute

execute() runs the command, returning a RunCmdOutput.

let retval: RunCmdOutput = RunCmd::new("echo \"Hello World\"").execute();

It returns the following.

pub struct RunCmdOutput {
    pub cmd: String,
    pub stdout: String,
    pub stderr: String,
    pub exitcode: i32
}
Commit count: 3

cargo fmt