Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

Commit

Permalink
Change verbosity multiplicity > 3 to warning (#175)
Browse files Browse the repository at this point in the history
Instead of a hard error, -vvvv now defaults to a log level of 3. As
get_loglevel can no longer fail, also change it to not return an
Option.

Fixes #171
  • Loading branch information
chrisvittal authored and vitiral committed Sep 13, 2017
1 parent 6839d0c commit 09a5662
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/cmd/mod.rs
Expand Up @@ -48,16 +48,17 @@ mod server;
#[cfg(test)]
mod tests;

pub fn get_loglevel(matches: &ArgMatches) -> Option<(u8, bool)> {
pub fn get_loglevel(matches: &ArgMatches) -> (u8, bool) {
let verbosity = match matches.occurrences_of("verbose") {
v @ 0...3 => v,
_ => {
eprintln!("ERROR: verbosity cannot be higher than 3");
return None;
// v > 3
eprintln!("WARN: verbosity cannot be higher than 3, defaulting to 3");
3
}
} as u8;
let quiet = matches.is_present("quiet");
Some((verbosity, quiet))
(verbosity, quiet)
}

#[cfg(feature = "beta")]
Expand Down Expand Up @@ -90,10 +91,8 @@ where
};

// initialze the logger
match get_loglevel(&matches) {
Some((v, q)) => logging::init_logger(q, v, true).unwrap(),
None => panic!("could not find loglevel"),
};
let (v, q) = get_loglevel(&matches);
logging::init_logger(q, v, true).unwrap();

// if we are updating, just do that and exit
if let Some(up) = matches.subcommand_matches("update") {
Expand Down

0 comments on commit 09a5662

Please sign in to comment.