diff --git a/src/args.rs b/src/args.rs index 006a715..21104fe 100644 --- a/src/args.rs +++ b/src/args.rs @@ -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) -> Result> { 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") +} diff --git a/src/main.rs b/src/main.rs index b5f6af7..2225c4f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,5 +7,5 @@ mod args; mod tests; fn main() { - let matches = args::get_matches(); + args::get_matches(); }