Skip to content

Commit 9278ebb

Browse files
committed
release-0.1.0
1 parent d3612ed commit 9278ebb

7 files changed

Lines changed: 239 additions & 43 deletions

File tree

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/publish.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: publish
2+
3+
on:
4+
push:
5+
tags:
6+
- release-*.*.*
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
publish:
13+
name: ${{ matrix.name }}
14+
15+
runs-on: ${{ matrix.os }}
16+
17+
strategy:
18+
matrix:
19+
os: [macos-latest, windows-latest]
20+
include:
21+
- os: macos-latest
22+
name: MacOS Binary 64-Bit
23+
target: x86_64-apple-darwin
24+
target2: aarch64-apple-darwin
25+
env:
26+
MACOSX_DEPLOYMENT_TARGET: 10.7
27+
28+
- os: windows-latest
29+
name: Windows Binary 64-Bit
30+
target: x86_64-pc-windows-msvc
31+
32+
steps:
33+
- name: Check out repository
34+
uses: actions/checkout@v4
35+
36+
- name: Add rustup default target
37+
run: rustup target add ${{ matrix.target }}
38+
39+
- name: Add rustup Apple ARM64 target
40+
if: ${{ matrix.os == 'macos-latest' }}
41+
run: rustup target add ${{ matrix.target2 }}
42+
43+
- name: Build default target in release mode
44+
run: cargo build --release --target ${{ matrix.target }} --locked
45+
46+
- name: Build Apple ARM64 target in release mode
47+
if: ${{ matrix.os == 'macos-latest' }}
48+
run: cargo build --release --target ${{ matrix.target2 }} --locked
49+
50+
- name: Create zip file on Windows
51+
if: ${{ matrix.os == 'windows-latest' }}
52+
run: |
53+
choco install zip
54+
cd target/${{ matrix.target }}/release
55+
zip gstats-0.1.0-${{ matrix.target }}.zip gstats.exe
56+
cd ../../..
57+
58+
- name: Create tar.gz file on macOS
59+
if: ${{ matrix.os == 'macos-latest' }}
60+
run: |
61+
chmod +x target/${{ matrix.target }}/release/gstats
62+
tar -zcf target/${{ matrix.target }}/release/gstats-0.1.0-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release gstats
63+
chmod +x target/${{ matrix.target2 }}/release/gstats
64+
tar -zcf target/${{ matrix.target2 }}/release/gstats-0.1.0-${{ matrix.target2 }}.tar.gz -C target/${{ matrix.target2 }}/release gstats
65+
66+
- name: Upload release and assets to GitHub
67+
uses: svenstaro/upload-release-action@v2
68+
with:
69+
repo_token: ${{ secrets.GITHUB_TOKEN }}
70+
tag: "release-0.1.0-${{ github.run_number }}"
71+
release_name: gstats 0.1.0
72+
file_glob: true
73+
file: target/*/release/gstats-0.1.0-*.{zip,tar.gz}

.github/workflows/pull_request.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Rust
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Build
18+
run: cargo build --verbose
19+
- name: Run tests
20+
run: cargo test --verbose

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55
authors = ["cqb13 <cqb13.dev@gmail.com>"]
66
license = "MIT"
7-
description = "A CLI tool for getting information on github repositories."
7+
description = "A CLI tool for getting information on GitHub repositories and users."
88
readme = "./README.md"
99
homepage = "https://github.com/cqb13/github-stats"
1010
repository = "https://github.com/cqb13/github-stats"

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Github Stats (gstats)
2+
3+
`gstats` is a CLI tool that provides comprehensive statistics and information about GitHub repositories and users.
4+
5+
## Installation
6+
7+
`gstats` can be installed either by cloning the repository and building from source or by downloading a precompiled executable from the release page. Below are the instructions for both methods:
8+
9+
### Installing from Source
10+
11+
1. **Clone the Repository**:
12+
Clone `gstats` from GitHub to your local machine using the following command:
13+
14+
```bash
15+
git clone https://github.com/cqb13/github-stats
16+
cd gstats
17+
```
18+
19+
2. **Build and Install with Cargo** (requires Rust's cargo tool):
20+
If you have Rust and Cargo installed, you can directly build and install the application using:
21+
22+
```bash
23+
cargo build --release
24+
./target/release/gstats install
25+
```
26+
27+
### Installing from Precompiled Executables
28+
29+
1. **Download the Latest Release**:
30+
Go to the [Releases page](rhttps://github.com/cqb13/github-stats/releases) of the `gstats` repository and download the appropriate executable for your operating system.
31+
32+
2. **Run Install Command**:
33+
After downloading, you need to run the installation command. Assuming you have downloaded `gstats.exe`, you can install it by navigating to the download location and running:
34+
35+
```bash
36+
./gstats install
37+
```
38+
39+
This command will set up `gstats` on your system, making it ready for use.
40+
41+
### Post-Installation
42+
43+
After installing `gstats`, you can run `gstats help` to see all available commands and how to use them. Make sure that the installation path of `gstats` is added to your system's PATH, so it can be run from any terminal session.
44+
45+
## Features
46+
47+
- **Version**: Display the current version of `gstats`.
48+
- **Install**: Installs the necessary files and directories for the tool.
49+
- **All Stats**: Fetches all available statistics for a specified repository in JSON format.
50+
- **Releases**: Provides information about the releases of a specified repository.
51+
- **User Info**: Retrieves detailed information about a GitHub user.
52+
53+
## Usage
54+
55+
Below are the commands available in `gstats`:
56+
57+
### General
58+
59+
- `gstats help`: Displays help information about the commands.
60+
61+
### Version
62+
63+
- `gstats version`: Shows the current version of `gstats`.
64+
65+
### Repository Statistics
66+
67+
- `gstats all -u <USER> -r <REPOSITORY> [-o <OUTPUT>] [-d]`
68+
- `-u, --user USER`: The owner of the repository.
69+
- `-r, --repository REPOSITORY`: The name of the repository.
70+
- `-o, --output OUTPUT`: Optional. File path to save the JSON output.
71+
- `-d, --display`: Optional. Converts JSON to a more readable format (some data may be omitted).
72+
73+
### Release Information
74+
75+
- `gstats releases -u <USER> -r <REPOSITORY> [-i] [-l] [-o <OUTPUT>] [-a] [-d]`
76+
- `-u, --user USER`: The owner of the repository.
77+
- `-r, --repository REPOSITORY`: The name of the repository.
78+
- `-i, --individual`: Optional. Includes download counts per release.
79+
- `-l, --link`: Optional. Provides download links for releases.
80+
- `-o, --output OUTPUT`: Optional. File path to save the JSON output.
81+
- `-a, --all`: Optional. Fetches all JSON data from the request.
82+
- `-d, --display`: Optional. Converts JSON to a more readable format (some data may be omitted).
83+
84+
### User Information
85+
86+
- `gstats user -u <USER> [-o <OUTPUT>] [-d]`
87+
- `-u, --user USER`: The GitHub username to retrieve information for.
88+
- `-o, --output OUTPUT`: Optional. File path to save the JSON output.
89+
- `-d, --display`: Optional. Converts JSON to a more readable format (some data may be omitted).
90+
91+
## Contributing
92+
93+
Contributions are welcome! Feel free to fork this repository and submit pull requests.
94+
95+
## License
96+
97+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

src/commands/all.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,31 @@ pub fn all_command(owner: String, repo: String, output: Option<PathBuf>, display
3232

3333
fn simplify_and_display_json(json: &Value) {
3434
// General Info
35-
let name = &json["name"].as_str().unwrap_or("None");
36-
let description = &json["description"].as_str().unwrap_or("None");
35+
let name = json["name"].as_str().unwrap_or("None");
36+
let description = json["description"].as_str().unwrap_or("None");
3737
// Repo Status
38-
let forking = &json["allow_forking"];
39-
let archived = &json["archived"];
40-
let fork = &json["fork"];
41-
let disabled = &json["disabled"];
42-
let private = &json["private"];
38+
let forking = json["allow_forking"].as_bool().unwrap();
39+
let archived = json["archived"].as_bool().unwrap();
40+
let fork = json["fork"].as_bool().unwrap();
41+
let disabled = json["disabled"].as_bool().unwrap();
42+
let private = json["private"].as_bool().unwrap();
4343
// Activity Metrics
44-
let stars = &json["stargazers_count"];
45-
let forks = &json["forks_count"];
46-
let watches = &json["watchers_count"];
47-
let open_issues = &json["open_issues_count"];
44+
let stars = json["stargazers_count"].as_i64().unwrap_or(0);
45+
let forks = json["forks_count"].as_i64().unwrap_or(0);
46+
let watches = json["watchers_count"].as_i64().unwrap_or(0);
47+
let open_issues = json["open_issues_count"].as_i64().unwrap_or(0);
4848
// Repository URLs
49-
let html_url = &json["html_url"].as_str().unwrap_or("None");
50-
let clone_url = &json["clone_url"].as_str().unwrap_or("None");
51-
let homepage = &json["homepage"].as_str().unwrap_or("None");
49+
let html_url = json["html_url"].as_str().unwrap_or("None");
50+
let clone_url = json["clone_url"].as_str().unwrap_or("None");
51+
let homepage = json["homepage"].as_str().unwrap_or("None");
5252
// Development Details
53-
let language = &json["language"].as_str().unwrap_or("None");
54-
let default_branch = &json["default_branch"].as_str().unwrap_or("None");
55-
let license = &json["license"]["name"].as_str().unwrap_or("None");
53+
let language = json["language"].as_str().unwrap_or("None");
54+
let default_branch = json["default_branch"].as_str().unwrap_or("None");
55+
let license = json["license"]["name"].as_str().unwrap_or("None");
5656
// Important Dates
57-
let created_at = &json["created_at"].as_str().unwrap_or("None");
58-
let updated_at = &json["updated_at"].as_str().unwrap_or("None");
59-
let pushed_at = &json["pushed_at"].as_str().unwrap_or("None");
57+
let created_at = json["created_at"].as_str().unwrap_or("None");
58+
let updated_at = json["updated_at"].as_str().unwrap_or("None");
59+
let pushed_at = json["pushed_at"].as_str().unwrap_or("None");
6060

6161
println!("GENERAL INFO");
6262
println!(" {:<14}: {}", "Name", name);
@@ -78,14 +78,14 @@ fn simplify_and_display_json(json: &Value) {
7878
println!("REPOSITORY URLS");
7979
println!(" {:<14}: {}", "HTML URL", html_url);
8080
println!(" {:<14}: {}", "Clone URL", clone_url);
81-
if homepage != &"" && homepage != &"None" {
81+
if homepage != "" && homepage != "None" {
8282
println!(" {:<14}: {}", "Homepage", homepage);
8383
}
8484
println!();
8585
println!("DEVELOPMENT DETAILS");
8686
println!(" {:<14}: {}", "Language", language);
8787
println!(" {:<14}: {}", "Default branch", default_branch);
88-
if license != &"None" {
88+
if license != "None" {
8989
println!(" {:<14}: {}", "License", license);
9090
}
9191
println!();

src/commands/releases.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -188,42 +188,42 @@ fn simplify_json_release_data(json: &Value) -> Vec<ReleaseData> {
188188
let mut download_data: Vec<ReleaseData> = Vec::new();
189189

190190
for release in json.as_array().unwrap() {
191-
let name = &release["name"].as_str().unwrap_or("None").to_string();
192-
let tag = &release["tag_name"].as_str().unwrap_or("None").to_string();
193-
let published_at = &release["published_at"]
191+
let name = release["name"].as_str().unwrap_or("None").to_string();
192+
let tag = release["tag_name"].as_str().unwrap_or("None").to_string();
193+
let published_at = release["published_at"]
194194
.as_str()
195195
.unwrap_or("None")
196196
.to_string();
197-
let created_at = &release["created_at"].as_str().unwrap_or("None").to_string();
198-
let html_url = &release["html_url"].as_str().unwrap_or("None").to_string();
199-
let body = &release["body"].as_str().unwrap_or("None").to_string();
197+
let created_at = release["created_at"].as_str().unwrap_or("None").to_string();
198+
let html_url = release["html_url"].as_str().unwrap_or("None").to_string();
199+
let body = release["body"].as_str().unwrap_or("None").to_string();
200200

201201
let mut download = ReleaseData::new(
202-
name.to_string(),
203-
tag.to_string(),
202+
name,
203+
tag,
204204
pretty_dates(&published_at),
205205
pretty_dates(&created_at),
206-
html_url.to_string(),
207-
body.to_string(),
206+
html_url,
207+
body,
208208
);
209209

210210
for asset in release["assets"].as_array().unwrap() {
211-
let download_url = &asset["browser_download_url"]
211+
let download_url = asset["browser_download_url"]
212212
.as_str()
213213
.unwrap_or("None")
214214
.to_string();
215-
let created_at = &asset["created_at"].as_str().unwrap_or("None").to_string();
216-
let downloads = &asset["download_count"].as_i64().unwrap_or(0);
217-
let name = &asset["name"].as_str().unwrap_or("None").to_string();
218-
let size = &asset["size"].as_i64().unwrap_or(0);
219-
let updated_at = &asset["updated_at"].as_str().unwrap_or("None").to_string();
215+
let created_at = asset["created_at"].as_str().unwrap_or("None").to_string();
216+
let downloads = asset["download_count"].as_i64().unwrap_or(0);
217+
let name = asset["name"].as_str().unwrap_or("None").to_string();
218+
let size = asset["size"].as_i64().unwrap_or(0);
219+
let updated_at = asset["updated_at"].as_str().unwrap_or("None").to_string();
220220

221221
let asset = Asset::new(
222-
download_url.to_string(),
222+
download_url,
223223
pretty_dates(&created_at),
224-
downloads.to_owned(),
225-
name.to_string(),
226-
size.to_owned(),
224+
downloads,
225+
name,
226+
size,
227227
pretty_dates(&updated_at),
228228
);
229229

0 commit comments

Comments
 (0)