Trait fluvio_command::CommandExt[][src]

pub trait CommandExt {
    fn inherit(&mut self) -> &mut Self;
fn display(&mut self) -> String;
fn result(&mut self) -> CommandResult; }

Adds useful extension methods to the Command type

Required methods

fn inherit(&mut self) -> &mut Self[src]

Inherit both stdout and stderr from this process.

Example

use std::process::Command;
use fluvio_command::CommandExt;
let _ = Command::new("echo")
    .arg("Hello world")
    .inherit()
    .status();

fn display(&mut self) -> String[src]

Return a stringified version of the Command.

use std::process::Command;
use fluvio_command::CommandExt;
let mut command = Command::new("echo");
command.arg("one").arg("two three");
let command_string: String = command.display();
assert_eq!(command_string, "echo one two three");

fn result(&mut self) -> CommandResult[src]

Returns a result signaling the outcome of executing this command.

use std::process::{Command, Output};
use fluvio_command::{CommandExt, CommandErrorKind};

// On success, we get the stdout and stderr output
let output: Output = Command::new("true").result().unwrap();

let error = Command::new("ls")
    .arg("does-not-exist")
    .result()
    .unwrap_err();
if let CommandErrorKind::ExitError(1i32, output) = error.source {
    assert_eq!(
        String::from_utf8_lossy(&output.stderr).to_string(),
        "ls: does-not-exist: No such file or directory\n",
    );
} else {
    panic!("should fail with stderr output");
}

let error = Command::new("foobar").result().unwrap_err();
assert!(matches!(error.source, CommandErrorKind::IoError(_)));
assert_eq!(error.command, "foobar");
Loading content...

Implementations on Foreign Types

impl CommandExt for Command[src]

Loading content...

Implementors

Loading content...