archive
/
md-pdf-rs
Archived
1
Fork 0

Add verbose flag and complex getter

This commit is contained in:
Jake Howard 2017-07-13 09:14:16 +01:00
parent c8cf6f0c51
commit 65a6c1b368
Signed by: jake
GPG Key ID: 57AFB45680EDD477
2 changed files with 14 additions and 2 deletions

View File

@ -1,4 +1,4 @@
use clap::{App, AppSettings, ArgMatches};
use clap::{App, AppSettings, ArgMatches, Arg};
#[cfg(test)]
use clap::Result;
@ -14,6 +14,13 @@ fn build() -> App<'static, 'static> {
.global_setting(AppSettings::ColoredHelp)
.global_setting(AppSettings::GlobalVersion)
.global_setting(AppSettings::StrictUtf8)
.arg(Arg::with_name("verbose")
.global(true)
.short("v")
.long("verbose")
.help("Show verbose output")
.multiple(true)
)
}
@ -25,3 +32,8 @@ pub fn get_matches() -> ArgMatches<'static> {
pub fn get_matches_for(args : Vec<String>) -> Result<ArgMatches<'static>> {
return build().get_matches_from_safe(args);
}
pub fn get_verbose(m : ArgMatches) -> u64 {
let sub = m.subcommand_matches(&m.subcommand_name().unwrap()).unwrap();
m.occurrences_of("verbose") + sub.occurrences_of("verbose")
}

View File

@ -7,5 +7,5 @@ mod args;
mod tests;
fn main() {
let matches = args::get_matches();
args::get_matches();
}