Skip to main content

Crate treesap

Crate treesap 

Source
Expand description

§treesap

A #[derive(Parser)] interface for sap.

treesap lets you declare your CLI arguments as a plain Rust struct and generates a parse() method that calls into sap under the hood.

Work in progress. Only bool fields mapped to long flags are currently functional. See the README for a full breakdown of implemented versus planned features.

§Usage

use treesap::Parser;

#[derive(Debug, Parser)]
struct Args {
    verbose: bool,
    dry_run: bool,
}

fn main() -> sap::Result<()> {
    let args = Args::parse()?;

    if args.verbose {
        println!("verbose mode enabled");
    }

    if args.dry_run {
        println!("dry-run: no changes will be made");
    }

    Ok(())
}

Derive Macros§

Parser
The Parser derive macro.