#command #macro #process #subprocess

cmdstruct

A lightweight macro for implementing commands with a struct

5 stable releases

new 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

#766 in Rust patterns

Download history 320/week @ 2024-03-20 67/week @ 2024-03-27 140/week @ 2024-04-03 8/week @ 2024-04-10 2/week @ 2024-04-24

152 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

~295–740KB
~18K SLoC