feature: add command to query tasks
This commit is contained in:
parent
71c11eaa84
commit
63c20cfc87
7 changed files with 184 additions and 8 deletions
15
src/main.rs
15
src/main.rs
|
|
@ -1,11 +1,15 @@
|
|||
use clap::{CommandFactory, Parser};
|
||||
use figment::{
|
||||
providers::{Env, Serialized},
|
||||
Figment,
|
||||
};
|
||||
use readwise_bulk_upload::config::{Command, Config};
|
||||
use readwise_bulk_upload::readwise::DocumentPayload;
|
||||
use readwise_bulk_upload::sql::TaskManager;
|
||||
use readwise_bulk_upload::task_manager::TaskManager;
|
||||
use readwise_bulk_upload::{Error, Result};
|
||||
use std::fs::File;
|
||||
use tabled::Table;
|
||||
use tracing_subscriber;
|
||||
use figment::{Figment, providers::{Serialized, Env}};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
|
|
@ -25,7 +29,6 @@ async fn main() -> Result<()> {
|
|||
}
|
||||
|
||||
async fn run(command: &Command) -> Result<()> {
|
||||
|
||||
match command {
|
||||
Command::LoadTasks { path } => {
|
||||
let file = File::open(path).map_err(|_| {
|
||||
|
|
@ -41,6 +44,12 @@ async fn run(command: &Command) -> Result<()> {
|
|||
|
||||
task_manager.load_tasks(documents).await?;
|
||||
}
|
||||
Command::Query => {
|
||||
let task_manager = TaskManager::new().await?;
|
||||
let tasks = task_manager.get_tasks::<DocumentPayload>(None, 25).await?;
|
||||
|
||||
println!("{}", Table::new(tasks));
|
||||
}
|
||||
Command::None => {
|
||||
Config::command().print_help()?;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue