mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-02-23 15:50:00 +01:00
imp(duration): use std::time::Duration everywhere
This gets rid of the time crate, which was necessary only while Duration wasn't stable in std.
This commit is contained in:
@@ -4,15 +4,14 @@ extern crate hyper;
|
||||
extern crate chrono;
|
||||
extern crate getopts;
|
||||
extern crate open;
|
||||
extern crate time;
|
||||
|
||||
use oauth2::GetToken;
|
||||
use chrono::{Local};
|
||||
use getopts::{HasArg,Options,Occur,Fail};
|
||||
use std::env;
|
||||
use std::default::Default;
|
||||
use time::Duration;
|
||||
use std::thread::sleep_ms;
|
||||
use std::time::Duration;
|
||||
use std::thread::sleep;
|
||||
|
||||
|
||||
fn usage(program: &str, opts: &Options, err: Option<Fail>) -> ! {
|
||||
@@ -54,9 +53,7 @@ fn main() {
|
||||
token_uri: Default::default(),
|
||||
auth_uri: Default::default(),
|
||||
redirect_uris: Default::default(),
|
||||
client_email: None,
|
||||
auth_provider_x509_cert_url: None,
|
||||
client_x509_cert_url: None
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
println!("THIS PROGRAM PRINTS ALL COMMUNICATION TO STDERR !!!");
|
||||
@@ -69,9 +66,9 @@ fn main() {
|
||||
You have time until {} to do that.
|
||||
Do not terminate the program until you deny or grant access !",
|
||||
pi.user_code, pi.verification_url, pi.expires_at.with_timezone(&Local));
|
||||
let delay = Duration::seconds(5);
|
||||
println!("Browser opens automatically in {} seconds", delay);
|
||||
sleep_ms(delay.num_milliseconds() as u32);
|
||||
let delay = Duration::from_secs(5);
|
||||
println!("Browser opens automatically in {:?} seconds", delay);
|
||||
sleep(delay);
|
||||
open::that(&pi.verification_url).ok();
|
||||
println!("DONE - waiting for authorization ...");
|
||||
}
|
||||
@@ -81,7 +78,7 @@ fn main() {
|
||||
connector: hyper::net::HttpConnector
|
||||
});
|
||||
|
||||
match oauth2::Authenticator::new(&secret, StdoutHandler, client,
|
||||
match oauth2::Authenticator::new(&secret, StdoutHandler, client,
|
||||
oauth2::NullStorage, None).token(&m.free) {
|
||||
Ok(t) => {
|
||||
println!("Authentication granted !");
|
||||
@@ -94,4 +91,4 @@ fn main() {
|
||||
std::process::exit(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user