Add -v option to print out logs (>= info) (#164)
This commit is contained in:
committed by
Roey Darwish Dror
parent
680f9a6d19
commit
232c886be6
@@ -117,6 +117,10 @@ pub struct CommandLineArgs {
|
||||
/// Do not perform upgrades for the given steps
|
||||
#[structopt(long = "disable", raw(possible_values = "&Step::possible_values()"))]
|
||||
disable: Vec<Step>,
|
||||
|
||||
/// Output logs
|
||||
#[structopt(short = "v", long = "verbose")]
|
||||
verbose: bool,
|
||||
}
|
||||
|
||||
/// Represents the application configuration
|
||||
@@ -189,4 +193,9 @@ impl Config {
|
||||
pub fn no_retry(&self) -> bool {
|
||||
self.opt.no_retry
|
||||
}
|
||||
|
||||
/// Tell whether we should print log.
|
||||
pub fn verbose(&self) -> bool {
|
||||
self.opt.verbose
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(clippy::cognitive_complexity)]
|
||||
|
||||
mod config;
|
||||
mod ctrlc;
|
||||
mod error;
|
||||
@@ -14,6 +16,7 @@ use self::error::{Error, ErrorKind};
|
||||
use self::report::Report;
|
||||
use self::steps::*;
|
||||
use self::terminal::*;
|
||||
use env_logger::Env;
|
||||
use failure::{Fail, ResultExt};
|
||||
use log::debug;
|
||||
#[cfg(feature = "self-update")]
|
||||
@@ -73,7 +76,11 @@ fn run() -> Result<(), Error> {
|
||||
}
|
||||
}
|
||||
|
||||
env_logger::init();
|
||||
let mut env = Env::default();
|
||||
if config.verbose() {
|
||||
env = env.filter_or("LOG_LEVEL", "info");
|
||||
}
|
||||
env_logger::init_from_env(env);
|
||||
|
||||
let git = git::Git::new();
|
||||
let mut git_repos = git::Repositories::new(&git);
|
||||
|
||||
Reference in New Issue
Block a user