Browse Source

Save registration

master
Julio Biason 6 years ago
parent
commit
438f37f77d
  1. 2
      .gitignore
  2. 10
      Cargo.lock
  3. 2
      Cargo.toml
  4. 25
      src/main.rs

2
.gitignore vendored

@ -5,3 +5,5 @@
/target /target
**/*.rs.bk **/*.rs.bk
mastodon.toml

10
Cargo.lock generated

@ -269,6 +269,7 @@ dependencies = [
"serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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)", "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)", "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]] [[package]]
name = "try-lock" name = "try-lock"
version = "0.2.2" 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-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-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 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-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 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" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"

2
Cargo.toml

@ -5,4 +5,4 @@ authors = ["Julio Biason <julio.biason@pm.me>"]
edition = "2018" edition = "2018"
[dependencies] [dependencies]
elefren = "0.19" elefren = { version = "0.19", features = ["toml"] }

25
src/main.rs

@ -1,12 +1,19 @@
use elefren::prelude::*; use elefren::prelude::*;
use elefren::helpers::cli; use elefren::helpers::cli;
use elefren::helpers::toml;
fn main() { fn main() {
let registration = Registration::new("https://functional.cafe") let client = if let Ok(data) = toml::from_file("mastodon.toml") {
.client_name("downfav") Mastodon::from(data)
.build() } else {
.unwrap(); let registration = Registration::new("https://functional.cafe")
let client = cli::authenticate(registration).unwrap(); .client_name("downfav")
.build()
.unwrap();
let mastodon = cli::authenticate(registration).unwrap();
toml::to_file(&*mastodon, "mastodon.toml").unwrap();
mastodon
};
client client
.favourites().unwrap() .favourites().unwrap()
@ -14,4 +21,12 @@ fn main() {
.take(2) .take(2)
.for_each(move |record| println!("{:#?}", record)) .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.
} }

Loading…
Cancel
Save