-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
users.rs
37 lines (33 loc) · 963 Bytes
/
users.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use hubcaps::{Credentials, Github};
use std::env;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
pretty_env_logger::init();
let token = env::var("GITHUB_TOKEN")?;
let github = Github::new(
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
Credentials::Token(token),
)?;
match github.users().authenticated().await {
Ok(me) => println!("{:#?}", me),
Err(err) => println!("err {:#?}", err),
}
match github
.users()
.get(
env::var("GH_USERNAME")
.ok()
.unwrap_or_else(|| "bors".into()),
)
.await
{
Ok(user) => println!("{:#?}", user),
Err(err) => println!("err {:#?}", err),
}
match github.users().authenticated_emails().await {
Ok(emails) => println!("{:#?}", emails),
Err(err) => println!("err {:#?}", err),
}
Ok(())
}