summaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorPaul Woolcock <paul@woolcock.us>2018-08-31 05:57:59 -0400
committerPaul Woolcock <paul@woolcock.us>2018-08-31 07:26:03 -0400
commit034bd4e6d107f5a48f560327cc2800cb41995f13 (patch)
treee17fd8b3204290a8e3fdc441c9665073d48a8ca7 /README.md
parente284894d40e206adf8089482e340d7a9d0046d79 (diff)
Add a helper for completing authentication via the command line
Diffstat (limited to 'README.md')
-rw-r--r--README.md13
1 files changed, 2 insertions, 11 deletions
diff --git a/README.md b/README.md
index 500e62f..de34321 100644
--- a/README.md
+++ b/README.md
@@ -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")?;