wip: add logging capabilities

This commit is contained in:
Alexander Navarro 2025-05-08 16:52:01 -04:00
parent d84c58fd1c
commit 3d12877e27
5 changed files with 384 additions and 17 deletions

View file

@ -1,24 +1,34 @@
use std::fs::File;
use clap::Parser;
use readwise_bulk_upload::config::Args;
use readwise_bulk_upload::config::Config;
use readwise_bulk_upload::readwise::DocumentPayload;
use readwise_bulk_upload::sql::{TaskManager};
use readwise_bulk_upload::sql::TaskManager;
use readwise_bulk_upload::{Error, Result};
use std::fs::File;
use tracing_subscriber;
use figment::{Figment, providers::{Serialized, Env, Format}};
#[tokio::main]
async fn main() -> Result<()> {
let args = Args::parse();
let args: Config = Figment::new()
.merge(Serialized::defaults(Config::parse()))
.merge(Env::prefixed("APP_"))
.extract()?;
let file = File::open(args.path())
.map_err(|_| Error::Runtime(format!(
tracing_subscriber::fmt()
.with_max_level(args.verbose)
.init();
let file = File::open(args.path()).map_err(|_| {
Error::Runtime(format!(
r#"The file "{}" could not be open"#,
args.path().display()
)))?;
))
})?;
let documents: Vec<DocumentPayload> = serde_json::from_reader(file)?;
let task_manager = TaskManager::new().await?;
task_manager.load_tasks(documents).await?;
Ok(())