4 releases (2 breaking)

Uses old Rust 2015

0.3.0 Dec 5, 2018
0.2.1 Dec 4, 2018
0.2.0 Dec 3, 2018
0.1.0 Dec 3, 2018
0.0.0 Mar 15, 2018

#6 in #macro-use


Used in jockey_derive

MIT license

8KB
95 lines

Jockey Latest Version Build Status

Custom command-line parsers that practically write themselves.


Using jockey

Please refer to the latest docs.


lib.rs:

Jockey provides custom command-line parsers that practically write themselves.

This crate provides the Arguments trait which can be derived using #[derive(Arguments)]. That trait provides the parse_args method which parses command-line arguments by env::args().

The following code is an example of a simple command-line parser.

extern crate jockey;
#[macro_use]
extern crate jockey_derive;

use jockey::Arguments;
use std::env;

#[derive(Arguments, Default)]
struct MyArguments {
    pub my_arg: Option<String>,
    pub my_flag: bool,
}

fn main() {
    let args = MyArguments::parse_args(env::args())
        .expect("Error parsing command-line options");

    println!("--my-arg = {:?}", args.my_arg);
    println!("--my-flag = {}", args.my_flag);
}

A more sophisticated example using field attributes can be found in the Arguments documentation.

No runtime deps