args: Change quiet to verbose since default behavior is quiet

This commit is contained in:
cohenarthur 2020-04-18 16:27:21 +02:00
parent fd44896c2b
commit 70f0acfca7
4 changed files with 13 additions and 7 deletions

View file

@ -20,8 +20,8 @@ pub struct Args {
#[structopt(short, long, default_value = "20")]
pub tries: usize,
#[structopt(short, long, default_value = "true")]
pub quiet: bool,
#[structopt(short, long, parse(try_from_str), default_value = "false")]
pub verbose: bool,
}
impl Args {

View file

@ -15,16 +15,21 @@ impl Logger {
format!("{}", Local::now())
}
/// Display an INFO message
pub fn info(message: String) {
/// Write a log message to stdout
fn write_log(header: ColoredString, message: String) {
// Sadly we can't use a static format litteral so we have to retype
// this for every function...
println!("{}: [{}] {}", Logger::get_timestamp(), "INFO".blue(), message);
println!("{}: [{}] {}", Logger::get_timestamp(), header, message);
}
/// Display an INFO message
pub fn info(message: String) {
Logger::write_log("INFO".blue(), message);
}
/// Display a WARNING message
pub fn warn(message: String) {
println!("{}: [{}] {}", Logger::get_timestamp(), "WARN".yellow(), message);
Logger::write_log("WARN".yellow(), message);
}
/// Display an ERROR message

View file

@ -110,7 +110,7 @@ impl Scraper {
scraper.visited_urls.lock().unwrap().insert(url.to_string());
if !scraper.args.quiet {
if scraper.args.verbose {
info!("Downloaded {}", url);
}
}

View file

@ -6,3 +6,4 @@
94.91624474525452, 47.318924236297605, 38.720614719390866
94.61654992103577, 57.59067335128784, 24.995196104049683
95.28456358909607, 46.86330976486206, 24.708560609817503
77.68792352676391, 39.08626494407654, 19.765260219573975

1 1 1 1
6 94.91624474525452 47.318924236297605 38.720614719390866
7 94.61654992103577 57.59067335128784 24.995196104049683
8 95.28456358909607 46.86330976486206 24.708560609817503
9 77.68792352676391 39.08626494407654 19.765260219573975