#command #macro #subprocess #process

cmdstruct

A lightweight macro for implementing commands with a struct

4 stable releases

2.0.0 Apr 3, 2024
1.2.0 Mar 26, 2024
1.1.0 Mar 25, 2024
1.0.0 Mar 25, 2024

#534 in Rust patterns

Download history 354/week @ 2024-03-22 144/week @ 2024-03-29 34/week @ 2024-04-05 3/week @ 2024-04-12

535 downloads per month
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

~0.4–0.8MB
~20K SLoC