simple-cmd

Crates.iosimple-cmd
lib.rssimple-cmd
version
sourcesrc
created_at2023-12-21 20:26:43.230595
updated_at2025-02-13 08:22:22.918735
descriptioncommand line utility for spawning commands
homepagehttps://github.com/sephiroth74/simple-cmd
repositoryhttps://github.com/sephiroth74/simple-cmd
max_upload_size
id1077464
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Alessandro Crugnola (sephiroth74)

documentation

README

simple-cmd

crates.io ci

Rust command exeuctor

Example:

use simple_cmd::Cmd;
use simple_cmd::prelude::*;
use tracing::trace;
use std::time::Duration;

pub fn main() {
    let cmd = Cmd::builder("sleep")
        .arg("1")
        .timeout(Some(Duration::from_millis(100)))
        .with_debug(true)
        .build();
    let output = cmd.output().expect("failed to wait for command");
    
    trace!("output: {:#?}", output);
    assert!(!output.status.success());
    assert!(!output.interrupt());
    assert!(output.kill());
}

Piping:

use simple_cmd::Cmd;
use simple_cmd::prelude::*;

fn test_pipe() {
    let builder = Cmd::builder("echo").args(&["hello pretty world"]).with_debug(true);
    let command1 = builder.build();

    let mut command2 = Command::new("sed");
    command2.args(&["s/pretty/_/"]);
    command2.stdout(Stdio::piped());

    let result = command1.pipe(command2).unwrap();
    let output = result.stdout.as_str().unwrap().trim();

    assert!(result.success());
    assert_eq!("hello _ world", output);
}

Commit count: 38

cargo fmt