synchronizator/src/main.rs

25 lines
672 B
Rust

use std::fs::File;
use clap::Parser;
use readwise_bulk_upload::config::Args;
use readwise_bulk_upload::readwise::DocumentPayload;
use readwise_bulk_upload::sql::{TaskManager};
use readwise_bulk_upload::{Error, Result};
#[tokio::main]
async fn main() -> Result<()> {
let args = Args::parse();
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(())
}