Crate jockey

source ·
Expand description

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;
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.


Error type for this crate.


Represents a set of command-line arguments that can be parsed.
Implemented by types parsable in Arguments::parse_args().

Type Definitions

Result type for this crate.