This commit is contained in:
Adam Cooper 2025-01-09 09:42:48 -05:00
parent d60e4958cc
commit 2a20538f0c

View file

@ -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<Client, Box<dyn std::error::Error>> {
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<Entries> {
}
*/
// #[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(())
}