summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorPaul Woolcock <paul@woolcock.us>2018-08-24 23:39:27 -0400
committerPaul Woolcock <paul@woolcock.us>2018-08-25 09:13:34 -0400
commit1436c28e424bccdd8d2ae647c07d551cc858ebb6 (patch)
treec647d116965e89a0cd4bf321dbbebba565631b23 /examples
parentae4d5dffe55564d4a93c9b7b9df2e5da052a1c9f (diff)
duplicate the AppBuilder api in Registration
Closes #13
Diffstat (limited to 'examples')
-rw-r--r--examples/register.rs25
1 files changed, 9 insertions, 16 deletions
diff --git a/examples/register.rs b/examples/register.rs
index 052cf71..82f6344 100644
--- a/examples/register.rs
+++ b/examples/register.rs
@@ -2,16 +2,11 @@
#![cfg_attr(not(feature = "toml"), allow(unused_imports))]
extern crate elefren;
-pub use self::elefren::{Data, MastodonClient};
+pub use self::elefren::prelude::*;
+pub use self::elefren::apps::prelude::*;
use std::{error::Error, io};
-use self::elefren::{
- apps::{App, Scopes},
- Mastodon,
- Registration,
-};
-
#[cfg(feature = "toml")]
use self::elefren::data::toml;
@@ -34,20 +29,18 @@ pub fn get_mastodon_data() -> Result<Mastodon, Box<Error>> {
#[cfg(feature = "toml")]
pub fn register() -> Result<Mastodon, Box<Error>> {
- let mut app = App::builder();
- app.client_name("elefren-examples")
- .scopes(Scopes::All)
- .website("https://github.com/pwoolcoc/elefren");
-
let website = read_line("Please enter your mastodon instance url:")?;
- let registration = Registration::new(website.trim());
- let registered = registration.register(app)?;
- let url = registered.authorize_url()?;
+ let registration = Registration::new(website.trim())
+ .client_name("elefren-examples")
+ .scopes(Scopes::All)
+ .website("https://github.com/pwoolcoc/elefren")
+ .register()?;
+ let url = registration.authorize_url()?;
println!("Click this link to authorize on Mastodon: {}", url);
let code = read_line("Paste the returned authorization code: ")?;
- let mastodon = registered.complete(code)?;
+ let mastodon = registration.complete(code)?;
// Save app data for using on the next run.
toml::to_file(&*mastodon, "mastodon-data.toml")?;