Docs

1 optparse

downloads build

1.1 Table of Contents

[TOC]

1.2 License

This project is licensed under GPLv3.

1.3 Installation

To add optparse to you Project by downloading it from crates.io or simply add it to your dependencies:

[dependencies]
optparse = ["0.1.0"]

1.4 Documentation

The documentation can be found

1.5 Usage

// import the crate
use optparse;

// functions/closures must take String as their only parameter
// and not return anything
fn hello(arg: String) {
    println!("Hello {} \o/", arg);
}
fn main() {
    // create a new parser with a parser description
    let mut parser = optargs::Parser::new("Example Description");

    // register a flag and a corresponding function to be called
    // from the command line
    // register!(flag, command description, function/closure, parser);
    register!("-welcome", "Example Description", hello, parser);

    // run the parser using the arguments from std::env
    // parse!(arguments, arguments length, parser)
    let args = std::env::args().collect();
    parse!(args.clone(), args.len() as u8, parser);
}

1.6 Work in Progress

:::info You want to contribute? Feel free to leave a comment or create a pull request. :::