-
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gists+examples: Extend
GistsHandler
by adding star(...)
The `star(...)` function takes a `gist_id` and 'stars' it. Has no observable effect on the gist if it is already starred.
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use octocrab::Octocrab; | ||
|
||
#[tokio::main] | ||
async fn main() -> octocrab::Result<()> { | ||
let token = std::env::var("GITHUB_TOKEN").expect("GITHUB_TOKEN env variable is required"); | ||
let gist_id = if let Some(gist_id) = std::env::args().nth(1) { | ||
gist_id | ||
} else { | ||
eprintln!("error: Need to pass gist id on argv"); | ||
std::process::exit(1); | ||
}; | ||
|
||
let octocrab = Octocrab::builder().personal_token(token).build()?; | ||
octocrab.gists().star(gist_id).await?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters