#command #macro #subprocess #process

cmdstruct

A lightweight macro for implementing commands with a struct

5 stable releases

2.0.1 May 8, 2024
2.0.0 Apr 3, 2024
1.2.0 Mar 26, 2024
1.1.0 Mar 25, 2024
1.0.0 Mar 25, 2024

#813 in Rust patterns


Used in system-harness

MIT/Apache

8KB
80 lines

cmdstruct

A lightweight macro for implementing commands with a struct

Documentation

Usage

use cmdstruct::Command;

#[derive(Command)]
#[command(executable = "echo")]
struct Echo {

    /// Flag to provide
    #[arg(flag = "-n")]
    no_new_line: bool,

    /// String to echo
    #[arg]
    s: String

}

fn main() {
    let echo = Echo {
        no_new_line: true,
        s: "hello world".to_string()
    };

    echo.command().spawn();
}

Dependencies

~245–700KB
~17K SLoC