-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathwatching.rs
57 lines (50 loc) · 1.37 KB
/
watching.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use futures::prelude::*;
use hubcaps::{Credentials, Github, Result};
use std::env;
#[tokio::main]
async fn main() -> Result<()> {
pretty_env_logger::init();
let token = env::var("GITHUB_TOKEN").expect("example missing GITHUB_TOKEN");
let github = Github::new(
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
Credentials::Token(token),
)?;
println!("watched repos");
github
.activity()
.watching()
.iter()
.try_for_each(|repo| async move {
println!("{}", repo.full_name);
Ok(())
})
.await?;
println!("watch a repo");
let sub = github
.activity()
.watching()
.watch_repo("octocat", "Hello-World")
.await?;
println!("subscription: {:#?}", sub);
println!("get watching for repo");
let another = github
.activity()
.watching()
.get_for_repo("octocat", "Hello-World")
.await?;
println!("subscription: {:#?}", another);
println!("ignore a repo");
let ignore = github
.activity()
.watching()
.ignore_repo("octocat", "Hello-World")
.await?;
println!("subscription: {:#?}", ignore);
println!("unwatch a repo");
github
.activity()
.watching()
.unwatch_repo("octocat", "Hello-World")
.await?;
Ok(())
}