From 2a20538f0c4a130353ca6d852a6858ad4e97c56c Mon Sep 17 00:00:00 2001 From: Adam Cooper Date: Thu, 9 Jan 2025 09:42:48 -0500 Subject: [PATCH] Working! --- src/main.rs | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main.rs b/src/main.rs index 32e4380..b52824c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,33 +1,37 @@ use std::env; -use wallabag_api::types::{Config /*, EntriesFilter, SortBy, SortOrder*/ }; +use wallabag_api::types::Config; use wallabag_api::Client; -fn get_client() -> Result> { +fn get_client() -> Client { let config = Config { client_id: String::from("7_iwawqc3fc3k0k04s8cwwkkk8sgogkcw40swkgs4ocs8sk8wgo"), client_secret: env::var("WALLABAG_CLIENT_SECRET").expect("not set"), username: String::from("adam"), password: env::var("WALLABAG_PASSWORD").expect("not set"), - base_url: String::from("https://wallabag.theadamcooper.com/"), + base_url: String::from("https://wallabag.theadamcooper.com"), }; let client = Client::new(config); println!("{:?}", client); - Ok(client) + client } -/* -async fn get_entries(client: Client) -> ClientResult { -} -*/ - -// #[tokio::main] -/*async*/ fn main() -> std::io::Result<()> { +#[tokio::main] +async fn main() -> std::io::Result<()> { println!("Hello, world!"); - // get token (hard code at first0 - // let token = "badc0ffee"; - let _client = get_client(); - // get entries - // let all_entries = get_entries(client).await?.unwrap(); - // tag entries + let mut client: Client = get_client(); + let response = client.get_entries().await; + match response { + Err(e) => { + println!("Error: {}", e); + } + Ok(entries) => { + for entry in entries { + if entry.tags.len() == 0 { + let _ = client.add_tags_to_entry(entry.id, vec!["untagged"]).await; + println!("{:?}", entry.title); + } + } + } + } Ok(()) }