Crate cmdstruct

Source
Expand description

§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();
}

Traits§

Arg
A trait representing an argument to a command
Command
A trait representing a particular command

Derive Macros§

Command