-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathlabels.rs
36 lines (35 loc) · 919 Bytes
/
labels.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
use futures::prelude::*;
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),
)?;
// add labels associated with a pull
println!(
"{:#?}",
github
.repo("softprops", "hubcaps")
.pulls()
.get(121)
.labels()
.add(vec!["enhancement"])
.await?
);
// stream over all labels defined for a repo
github
.repo("rust-lang", "cargo")
.labels()
.iter()
.try_for_each(move |label| async move {
println!("{}", label.name);
Ok(())
})
.await?;
Ok(())
}