Skip to content
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ GitHub stats in the terminal, neofetch-style.
- Catppuccin-based terminal themes
- Optional JSON output for shell scripts and other tooling
- Language breakdowns with detailed table mode
- Repository breakdowns for language totals and estimated LoC
- Contribution and streak stats when authenticated

## Installation
Expand Down Expand Up @@ -60,9 +61,12 @@ Unauthenticated mode still works for public data, but GitHub rate limits are muc
```bash
ghfetch octocat
ghfetch user octocat --all
ghfetch user octocat --languages --ignore-forks
ghfetch repo rust-lang/rust
ghfetch repo https://github.com/rust-lang/rust
ghfetch org rust-lang --languages
ghfetch breakdown octocat --language Rust
ghfetch breakdown octocat --by repo
ghfetch octocat --json
ghfetch repo rust-lang/rust --theme latte
```
Expand All @@ -73,19 +77,22 @@ ghfetch repo rust-lang/rust --theme latte
- `ghfetch user <username>`
- `ghfetch repo <owner/repo|github-url|ssh-remote>`
- `ghfetch org <orgname>`
- `ghfetch breakdown <username>`

### Common flags

- `--json` prints structured output instead of a card
- `--no-color` disables ANSI styling
- `--theme <mocha|macchiato|frappe|latte>` selects the card palette
- `--verbose` prints API request diagnostics to stderr
- `--ignore-forks` / `--no-forks` excludes forked repositories from user, org, and breakdown repository totals

## Notes

- `ghfetch user <username>` shows a compact summary by default. Use `--all` to include every section, or specific section flags like `--repos` or `--languages`.
- `ghfetch org <orgname>` and `ghfetch repo <owner/repo|github-url|ssh-remote>` show language summaries by default.
- Detailed language mode (`--languages`) prints a wider table instead of the card view.
- `ghfetch breakdown <username>` shows which repositories contribute to language totals. Use `--language <name>`, `--repo <name|owner/name>`, `--by repo`, `--limit`, and `--repo-limit` to narrow the output. LoC is estimated from GitHub Linguist byte counts, not from per-author line ownership.

## Development

Expand Down
5 changes: 5 additions & 0 deletions src/api/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ pub struct ContributionDay {
#[derive(Debug, Deserialize, Clone)]
pub struct GraphQLRepo {
pub name: String,
pub name_with_owner: String,
pub description: Option<String>,
pub is_fork: bool,
pub is_private: bool,
Expand Down Expand Up @@ -142,6 +143,10 @@ fn parse_repo_nodes(nodes: &serde_json::Value) -> Vec<GraphQLRepo> {

repos.push(GraphQLRepo {
name: node["name"].as_str().unwrap_or_default().to_string(),
name_with_owner: node["nameWithOwner"]
.as_str()
.unwrap_or_default()
.to_string(),
description: node["description"].as_str().map(|s| s.to_string()),
is_fork: node["isFork"].as_bool().unwrap_or(false),
is_private: node["isPrivate"].as_bool().unwrap_or(false),
Expand Down
48 changes: 47 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ pub enum Command {
#[command(flatten)]
opts: OrgOpts,
},

/// Explain which repositories contribute to language totals
Breakdown {
/// GitHub username
username: String,

#[command(flatten)]
opts: BreakdownOpts,
},
}

#[derive(Clone, Copy, ValueEnum)]
Expand All @@ -82,6 +91,12 @@ pub enum SortBy {
Name,
}

#[derive(Clone, Copy, ValueEnum, PartialEq, Eq)]
pub enum BreakdownBy {
Language,
Repo,
}

#[derive(Parser)]
pub struct UserOpts {
/// Show only the languages section
Expand Down Expand Up @@ -117,7 +132,7 @@ pub struct UserOpts {
pub sort_by: SortBy,

/// Exclude forked repositories
#[arg(long)]
#[arg(long, visible_alias = "ignore-forks")]
pub no_forks: bool,
}

Expand Down Expand Up @@ -153,6 +168,37 @@ pub struct OrgOpts {
/// Maximum number of repos to display
#[arg(long, default_value_t = 10)]
pub repo_limit: usize,

/// Exclude forked repositories
#[arg(long, visible_alias = "ignore-forks")]
pub no_forks: bool,
}

#[derive(Parser)]
pub struct BreakdownOpts {
/// Group breakdown by language or repository
#[arg(long, value_enum, default_value_t = BreakdownBy::Language)]
pub by: BreakdownBy,

/// Show only this language
#[arg(long)]
pub language: Option<String>,

/// Show only this repository (name or owner/name)
#[arg(long)]
pub repo: Option<String>,

/// Maximum number of groups to display (0 means all)
#[arg(long, default_value_t = 10)]
pub limit: usize,

/// Maximum number of nested entries per group (0 means all)
#[arg(long, default_value_t = 10)]
pub repo_limit: usize,

/// Exclude forked repositories
#[arg(long, visible_alias = "ignore-forks")]
pub no_forks: bool,
}

impl UserOpts {
Expand Down
Loading
Loading