Add date argument, verbose flag

This commit is contained in:
Thomas Gideon 2023-07-15 15:38:48 -04:00
parent b8a1c5461b
commit cd08775783

View file

@ -1,5 +1,6 @@
use anyhow::{bail, format_err, Result};
use chrono::{DateTime, Local, LocalResult, NaiveDate, TimeZone, Utc};
use clap::{arg, command, Parser};
use html2md::parse_html;
use log::{debug, trace};
use megalodon::{
@ -23,13 +24,26 @@ struct Page<'a> {
newest: Option<&'a DateTime<Utc>>,
}
#[derive(Debug, Parser)]
#[command()]
struct Config {
#[arg(required = true)]
date: String,
#[arg(short)]
verbose: bool,
}
#[tokio::main]
async fn main() -> Result<()> {
env::set_var("RUST_LOG", format!("{}=debug", module_path!()));
env_logger::init();
let Config { date, verbose } = Config::parse();
if verbose {
env::set_var("RUST_LOG", format!("{}=debug", module_path!()));
} else {
env::set_var("RUST_LOG", format!("{}=none", module_path!()));
}
// TODO add clap and argument for date
let day = try_create_range("2023-07-01")?;
let day = try_create_range(date)?;
debug!("Date {}", day.end.format("%Y-%m-%d"));