|
|
@ -1,3 +1,5 @@ |
|
|
|
|
|
|
|
#![cfg_attr(not(feature = "toml"), allow(dead_code))] |
|
|
|
|
|
|
|
#![cfg_attr(not(feature = "toml"), allow(unused_imports))] |
|
|
|
extern crate elefren; |
|
|
|
extern crate elefren; |
|
|
|
|
|
|
|
|
|
|
|
pub use self::elefren::{Data, MastodonClient}; |
|
|
|
pub use self::elefren::{Data, MastodonClient}; |
|
|
@ -6,18 +8,22 @@ use std::{error::Error, io}; |
|
|
|
|
|
|
|
|
|
|
|
use self::elefren::{ |
|
|
|
use self::elefren::{ |
|
|
|
apps::{App, Scopes}, |
|
|
|
apps::{App, Scopes}, |
|
|
|
data::toml, |
|
|
|
|
|
|
|
Mastodon, |
|
|
|
Mastodon, |
|
|
|
Registration, |
|
|
|
Registration, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "toml")] |
|
|
|
|
|
|
|
use self::elefren::data::toml; |
|
|
|
|
|
|
|
|
|
|
|
#[allow(dead_code)] |
|
|
|
#[allow(dead_code)] |
|
|
|
|
|
|
|
#[cfg(feature = "toml")] |
|
|
|
fn main() -> Result<(), Box<Error>> { |
|
|
|
fn main() -> Result<(), Box<Error>> { |
|
|
|
register()?; |
|
|
|
register()?; |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[allow(dead_code)] |
|
|
|
#[allow(dead_code)] |
|
|
|
|
|
|
|
#[cfg(feature = "toml")] |
|
|
|
pub fn get_mastodon_data() -> Result<Mastodon, Box<Error>> { |
|
|
|
pub fn get_mastodon_data() -> Result<Mastodon, Box<Error>> { |
|
|
|
if let Ok(data) = toml::from_file("mastodon-data.toml") { |
|
|
|
if let Ok(data) = toml::from_file("mastodon-data.toml") { |
|
|
|
Ok(Mastodon::from(data)) |
|
|
|
Ok(Mastodon::from(data)) |
|
|
@ -26,6 +32,7 @@ pub fn get_mastodon_data() -> Result<Mastodon, Box<Error>> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "toml")] |
|
|
|
pub fn register() -> Result<Mastodon, Box<Error>> { |
|
|
|
pub fn register() -> Result<Mastodon, Box<Error>> { |
|
|
|
let mut app = App::builder(); |
|
|
|
let mut app = App::builder(); |
|
|
|
app.client_name("elefren-examples") |
|
|
|
app.client_name("elefren-examples") |
|
|
@ -48,6 +55,7 @@ pub fn register() -> Result<Mastodon, Box<Error>> { |
|
|
|
Ok(mastodon) |
|
|
|
Ok(mastodon) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "toml")] |
|
|
|
pub fn read_line(message: &str) -> Result<String, Box<Error>> { |
|
|
|
pub fn read_line(message: &str) -> Result<String, Box<Error>> { |
|
|
|
println!("{}", message); |
|
|
|
println!("{}", message); |
|
|
|
|
|
|
|
|
|
|
@ -56,3 +64,6 @@ pub fn read_line(message: &str) -> Result<String, Box<Error>> { |
|
|
|
|
|
|
|
|
|
|
|
Ok(input.trim().to_string()) |
|
|
|
Ok(input.trim().to_string()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(feature = "toml"))] |
|
|
|
|
|
|
|
fn main() { } |
|
|
|