diff options
author | Paul Woolcock <paul@woolcock.us> | 2018-08-31 05:57:59 -0400 |
---|---|---|
committer | Paul Woolcock <paul@woolcock.us> | 2018-08-31 07:26:03 -0400 |
commit | 034bd4e6d107f5a48f560327cc2800cb41995f13 (patch) | |
tree | e17fd8b3204290a8e3fdc441c9665073d48a8ca7 /README.md | |
parent | e284894d40e206adf8089482e340d7a9d0046d79 (diff) |
Add a helper for completing authentication via the command line
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 13 |
1 files changed, 2 insertions, 11 deletions
@@ -35,11 +35,11 @@ extern crate elefren; ```rust,no_run extern crate elefren; -use std::io; use std::error::Error; use elefren::prelude::*; use elefren::helpers::toml; // requires `features = ["toml"]` +use elefren::helpers::cli; fn main() -> Result<(), Box<Error>> { let mastodon = if let Ok(data) = toml::from_file("mastodon-data.toml") { @@ -59,16 +59,7 @@ fn register() -> Result<Mastodon, Box<Error>> { let registration = Registration::new("https://mastodon.social") .client_name("elefren-examples") .build()?; - let url = registration.authorize_url()?; - - println!("Click this link to authorize on Mastodon: {}", url); - println!("Paste the returned authorization code: "); - - let mut input = String::new(); - io::stdin().read_line(&mut input)?; - - let code = input.trim().to_string(); - let mastodon = registration.complete(&code)?; + let mastodon = cli::authenticate(registration)?; // Save app data for using on the next run. toml::to_file(&*mastodon, "mastodon-data.toml")?; |