Crate clapme[][src]

This crate defines the ClapMe trait and its custom derrive.

How to derive(ClapMe)

To begin with, let's look at an example of how you might actually use ClapMe in a real program.

#[macro_use]
extern crate clapme;

use std::path::PathBuf;
use clapme::ClapMe;

#[derive(Debug, ClapMe)]
struct Opt {
    /// Filling fraction
    filling_fraction: f64,
    /// Number of atoms
    N: u32,
    /// Output directory, working directory if not present
    dir: Option<PathBuf>,
    /// Activate verbose printing
    verbose: bool,
}

fn main() {
    let opt = Opt::from_args();
    println!("{:?}", opt);
}

The above example, however, doesn't show you what the options mean. So instead, this documentation will give examples in the following way:

#[derive(Debug, ClapMe)]
struct Opt {
    /// Filling fraction
    filling_fraction: f64,
    /// Number of atoms
    N: u32,
    /// Output directory, working directory if not present
    dir: Option<PathBuf>,
    /// Activate verbose printing
    verbose: bool,
}
assert_eq!(Opt::help_message("mc"), "mc 

USAGE:
    mc [FLAGS] [OPTIONS] --N <N> --filling_fraction <filling_fraction>

FLAGS:
        --verbose    Activate verbose printing

OPTIONS:
        --N <N>                                  Number of atoms
        --dir <dir>                              Output directory, working directory if not present
        --filling_fraction <filling_fraction>    Filling fraction");

Modules

clap

Re-export of clap

Structs

ArgInfo

Information needed to set up an argument.

Traits

ClapMe

Any type of trait ClapMe can be used as an argument value.