#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

#790 in Rust patterns

Download history 385/week @ 2024-03-25 137/week @ 2024-04-01 13/week @ 2024-04-08 2/week @ 2024-04-22 143/week @ 2024-05-06

146 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

~325–790KB
~19K SLoC