|
|
@ -34,10 +34,9 @@ fn main() { |
|
|
|
let config = dbg!(config::Config::get()); |
|
|
|
let config = dbg!(config::Config::get()); |
|
|
|
let client = dbg!(get_mastodon_connection()); |
|
|
|
let client = dbg!(get_mastodon_connection()); |
|
|
|
let top = dbg!(config.last_favorite.to_string()); |
|
|
|
let top = dbg!(config.last_favorite.to_string()); |
|
|
|
let storage: Box<dyn Storage> = if let Some(joplin) = &config.joplin { |
|
|
|
let storage: Box<dyn Storage> = match &config.joplin { |
|
|
|
Box::new(Joplin::new_from_config(&joplin)) |
|
|
|
Some(joplin) => Box::new(Joplin::new_from_config(&joplin)), |
|
|
|
} else { |
|
|
|
None => Box::new(Filesystem::new()), |
|
|
|
Box::new(Filesystem::new()) |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let most_recent_favourite = client |
|
|
|
let most_recent_favourite = client |
|
|
@ -51,7 +50,7 @@ fn main() { |
|
|
|
record |
|
|
|
record |
|
|
|
}) |
|
|
|
}) |
|
|
|
.fold(None, { |
|
|
|
.fold(None, { |
|
|
|
|first, current| { |
|
|
|
|first, current| -> Option<String> { |
|
|
|
if first.is_some() { |
|
|
|
if first.is_some() { |
|
|
|
first |
|
|
|
first |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -66,21 +65,22 @@ fn main() { |
|
|
|
/// Get a connection with Mastodon; if there is no set up with any account yet,
|
|
|
|
/// Get a connection with Mastodon; if there is no set up with any account yet,
|
|
|
|
/// requests one.
|
|
|
|
/// requests one.
|
|
|
|
fn get_mastodon_connection() -> Mastodon { |
|
|
|
fn get_mastodon_connection() -> Mastodon { |
|
|
|
if let Ok(data) = elefren_toml::from_file("mastodon.toml") { |
|
|
|
match elefren_toml::from_file("mastodon.toml") { |
|
|
|
Mastodon::from(data) |
|
|
|
Ok(data) => Mastodon::from(data), |
|
|
|
} else { |
|
|
|
Err(_) => { |
|
|
|
println!("Your server URL: "); |
|
|
|
println!("Your server URL: "); |
|
|
|
let mut server = String::new(); |
|
|
|
let mut server = String::new(); |
|
|
|
io::stdin() |
|
|
|
io::stdin() |
|
|
|
.read_line(&mut server) |
|
|
|
.read_line(&mut server) |
|
|
|
.expect("You need to enter yoru server URL"); |
|
|
|
.expect("You need to enter yoru server URL"); |
|
|
|
|
|
|
|
|
|
|
|
let registration = Registration::new(server.trim()) |
|
|
|
let registration = Registration::new(server.trim()) |
|
|
|
.client_name("downfav") |
|
|
|
.client_name("downfav") |
|
|
|
.build() |
|
|
|
.build() |
|
|
|
.unwrap(); |
|
|
|
.unwrap(); |
|
|
|
let mastodon = cli::authenticate(registration).unwrap(); |
|
|
|
let mastodon = cli::authenticate(registration).unwrap(); |
|
|
|
elefren_toml::to_file(&*mastodon, "mastodon.toml").unwrap(); |
|
|
|
elefren_toml::to_file(&*mastodon, "mastodon.toml").unwrap(); |
|
|
|
mastodon |
|
|
|
mastodon |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|