diff --git a/.gitignore b/.gitignore index eef1b55..bd7a517 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ /target **/*.rs.bk + +mastodon.toml diff --git a/Cargo.lock b/Cargo.lock index 2da3e1d..b408727 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -269,6 +269,7 @@ dependencies = [ "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "skeptic 0.13.4 (registry+https://github.com/rust-lang/crates.io-index)", "tap-reader 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1356,6 +1357,14 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "toml" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "try-lock" version = "0.2.2" @@ -1662,6 +1671,7 @@ dependencies = [ "checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" "checksum tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2910970404ba6fa78c5539126a9ae2045d62e3713041e447f695f41405a120c6" "checksum tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "350c9edade9830dc185ae48ba45667a445ab59f6167ef6d0254ec9d2430d9dd3" +"checksum toml 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "87c5890a989fa47ecdc7bcb4c63a77a82c18f306714104b1decfd722db17b39e" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" diff --git a/Cargo.toml b/Cargo.toml index ba81afb..c8298a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,4 +5,4 @@ authors = ["Julio Biason "] edition = "2018" [dependencies] -elefren = "0.19" +elefren = { version = "0.19", features = ["toml"] } diff --git a/src/main.rs b/src/main.rs index 87b750b..99c609d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,19 @@ use elefren::prelude::*; use elefren::helpers::cli; +use elefren::helpers::toml; fn main() { - let registration = Registration::new("https://functional.cafe") - .client_name("downfav") - .build() - .unwrap(); - let client = cli::authenticate(registration).unwrap(); + let client = if let Ok(data) = toml::from_file("mastodon.toml") { + Mastodon::from(data) + } else { + let registration = Registration::new("https://functional.cafe") + .client_name("downfav") + .build() + .unwrap(); + let mastodon = cli::authenticate(registration).unwrap(); + toml::to_file(&*mastodon, "mastodon.toml").unwrap(); + mastodon + }; client .favourites().unwrap() @@ -14,4 +21,12 @@ fn main() { .take(2) .for_each(move |record| println!("{:#?}", record)) ; + + // status + // status.account.acct (username) + // status.id (id) + // status.content + // status.media_attachments + // -> attachment.remote_url / attachment.url + // attachment. }