Skip to content

Instantly share code, notes, and snippets.

@mysteriouspants
Created September 13, 2015 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mysteriouspants/36baa2ee30d6ac47691a to your computer and use it in GitHub Desktop.
Save mysteriouspants/36baa2ee30d6ac47691a to your computer and use it in GitHub Desktop.
use clap::{Arg, ArgMatches, App, SubCommand};
pub fn parse_args<'a>() -> ArgMatches<'a, 'a> {
let matches = App::new("lod")
.version(&crate_version!()[..])
.author("Christopher R. Miller <mysteriouspants@outlook.com")
.about("LOD archive utility.")
.subcommand_required(true)
.versionless_subcommands(true)
.unified_help_message(true)
.subcommand_required_else_help(true)
.arg(Arg::with_name("verbose")
.short("v")
.multiple(true)
.help("Run in verbose mode"))
.subcommand(SubCommand::with_name("list")
.about("lists the files in a LOD archive")
.arg(Arg::with_name("archive_file")
.help("The archive to read.")
.index(1)
.required(true)))
.get_matches();
return matches;
}
extern crate clap;
#[macro_use] mod args;
use args::*;
fn main() {
let args = parse_args();
// presumably do more things here :)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment