8000 Updated Readme and Cleaned Code by DanDucky · Pull Request #3 · Ryu0118/Kusa · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Updated Readme and Cleaned Code #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,28 @@ $ brew install kusa
```
or download the appropriate file for your device from [releases](https://github.com/Ryu0118/Kusa/releases/tag/0.0.2)

### Building From Source

To build and run Kusa in your own environment,
Put your Github Personal Access Token with "read:user" enabled in "GITHUB_ACCESS_TOKEN" (src/main.rs, line 88)
Put your Github Personal Access Token with "read:user" enabled in "GITHUB_ACCESS_TOKEN" (src/main.rs, line 9)
```Rust
let github_access_token = "GITHUB_ACCESS_TOKEN";
static GITHUB_ACCESS_TOKEN : &str = "GITHUB_ACCESS_TOKEN";
```
then run this
```
$ cargo run <github user name>
```

## How To Generate A Github Access Token
Go to [github developer settings](https://github.com/settings/tokens).

Set the expiration date to "No Expiration".

No scopes are required for this application.

Click "Generate Token" and then copy the token it generates.

## Known issue
## Known Issue
Terminal.app on macOS does not support 24-bit color, so colors are not displayed.
Therefore, use iTerm2, Hyper, Warp or other terminals to display colors correctly.

Expand Down
11 changes: 7 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ use clap::Parser;
use graphql_client::{reqwest::post_graphql_blocking as post_graphql, GraphQLQuery};
use std::process;

//////////////////////////////////////////////////////////
static GITHUB_ACCESS_TOKEN : &str = "GITHUB_ACCESS_TOKEN";
//////////////////////////////////////////////////////////

#[derive(GraphQLQuery)]
#[graphql(
schema_path = "schema.graphql",
query_path = "query.graphql",
response_derives = "Debug"
)]

struct Kusa;

type Date = String;
Expand All @@ -21,14 +26,14 @@ type Date = String;
version = "0.0.2",
about = "Command to display Github Contributions graph on your shell"
)]

struct Command {
#[clap(name = "github user name", action = clap::ArgAction::Set)]
user_name: String,
}

struct DailyStatus {
date: String,
contribution_count: i64,
color: String,
}

Expand Down Expand Up @@ -73,7 +78,6 @@ fn get_github_contributions(response_data: kusa::ResponseData) -> (i64, Vec<Vec<
.iter()
.map(|daily_status| DailyStatus {
date: daily_status.date.to_string(),
contribution_count: daily_status.contribution_count,
color: daily_status.color.to_string(),
})
.collect()
Expand All @@ -89,7 +93,6 @@ fn get_github_contributions(response_data: kusa::ResponseData) -> (i64, Vec<Vec<
}

fn post_graphql_query(user_name: String) -> Result<kusa::ResponseData> {
let github_access_token = "GITHUB_ACCESS_TOKEN";

let variables = kusa::Variables { user_name };

Expand All @@ -98,7 +101,7 @@ fn post_graphql_query(user_name: String) -> Result<kusa::ResponseData> {
.default_headers(
std::iter::once((
reqwest::header::AUTHORIZATION,
reqwest::header::HeaderValue::from_str(&format!("Bearer {}", github_access_token))
reqwest::header::HeaderValue::from_str(&format!("Bearer {}", GITHUB_ACCESS_TOKEN))
.unwrap(),
))
.collect(),
Expand Down
0