Skip to content

Commit a3bccb8

Browse files
authored
Merge pull request #20 from Matars/MultipleProviders
Multiple providers
2 parents ce3c306 + e760520 commit a3bccb8

File tree

10 files changed

+751
-120
lines changed

10 files changed

+751
-120
lines changed

.github/workflows/update-aur.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,17 @@ jobs:
5151
sed -i 's/pkgver=.*/pkgver=${{ steps.get_version.outputs.version }}/' PKGBUILD
5252
sed -i 's|source=.*|source=("$pkgname-$pkgver.tar.gz::https://github.com/Matars/gitfetch/archive/refs/tags/v$pkgver.tar.gz")|' PKGBUILD
5353
sed -i "s/sha256sums=.*/sha256sums=('${{ steps.sha256.outputs.sha256 }}')/" PKGBUILD
54+
# Update dependencies
55+
sed -i 's/depends=.*/depends=("python-requests" "python-readchar")/' PKGBUILD
5456
5557
- name: Update .SRCINFO
5658
run: |
5759
cd aur-repo
5860
sed -i 's/pkgver = .*/pkgver = ${{ steps.get_version.outputs.version }}/' .SRCINFO
5961
sed -i 's|source = .*|source = gitfetch-python-${{ steps.get_version.outputs.version }}.tar.gz::https://github.com/Matars/gitfetch/archive/refs/tags/v${{ steps.get_version.outputs.version }}.tar.gz|' .SRCINFO
6062
sed -i "s/sha256sums = .*/sha256sums = ${{ steps.sha256.outputs.sha256 }}/" .SRCINFO
63+
# Update dependencies in .SRCINFO
64+
sed -i 's/depends = python-requests/depends = python-requests\n\tdepends = python-readchar/' .SRCINFO
6165
6266
- name: Commit and push
6367
run: |

.github/workflows/update-homebrew.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343
sed -i 's|url "https://github.com/Matars/gitfetch/archive/refs/tags/v.*"|url "https://github.com/Matars/gitfetch/archive/refs/tags/v${{ steps.get_version.outputs.version }}.tar.gz"|' homebrew-tap/Formula/gitfetch.rb
4444
sed -i 's|version ".*"|version "${{ steps.get_version.outputs.version }}"|' homebrew-tap/Formula/gitfetch.rb
4545
sed -i 's|sha256 ".*"|sha256 "${{ steps.sha256.outputs.sha256 }}"|' homebrew-tap/Formula/gitfetch.rb
46+
# Update dependencies
47+
sed -i 's|depends_on "requests"|depends_on "requests"\n depends_on "readchar"|' homebrew-tap/Formula/gitfetch.rb
4648
4749
- name: Commit and push
4850
run: |

README.md

Lines changed: 35 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# gitfetch
22

3-
A neofetch-style CLI tool for GitHub statistics. Display your GitHub profile and stats in a beautiful, colorful terminal interface.
3+
A neofetch-style CLI tool for GitHub, GitLab, Gitea, Forgejo, Codeberg, and Sourcehut statistics. Display your profile and stats from various git hosting platforms in a beautiful, colorful terminal interface.
44

55
<img width="3024" height="1964" alt="image" src="https://github.com/user-attachments/assets/bbb18d5d-4787-4998-a352-e8f4e59642c0" />
66

@@ -9,41 +9,33 @@ A neofetch-style CLI tool for GitHub statistics. Display your GitHub profile and
99
## Features
1010

1111
- Neofetch-style display with ASCII art
12-
- Comprehensive GitHub statistics
12+
- Comprehensive statistics from multiple git hosting platforms
1313
- Smart SQLite-based caching system for faster subsequent runs
1414
- Persistent configuration with default username support
15-
- Uses GitHub CLI (gh) for authentication - no rate limits!
1615
- Cross-platform support (macOS and Linux)
17-
- First-run initialization with interactive setup
16+
- First-run initialization with interactive provider selection
1817

19-
## Prerequisites
18+
## Supported Platforms
2019

21-
**GitHub CLI (gh) must be installed and authenticated:**
20+
- **GitHub** - Uses GitHub CLI (gh) for authentication
21+
- **GitLab** - Uses GitLab CLI (glab) for authentication
22+
- **Gitea/Forgejo/Codeberg** - Uses personal access tokens
23+
- **Sourcehut** - Uses personal access tokens
2224

23-
See installation instructions at: https://github.com/cli/cli#installation
25+
## Installation
2426

25-
### macOS
27+
`gitfetch` can be installed without any prerequisites. During first-run setup, you'll be guided to install and authenticate with the necessary CLI tools or provide access tokens for your chosen git hosting platform.
2628

27-
```bash
28-
brew install gh
29-
gh auth login
30-
```
31-
32-
### Linux
33-
34-
Then authenticate:
35-
36-
```bash
37-
gh auth login
38-
```
29+
## First-run Setup
3930

40-
### Verify Installation
31+
When you run `gitfetch` for the first time, you'll be prompted to:
4132

42-
```bash
43-
gh auth status
44-
```
33+
1. **Choose your git hosting provider** (GitHub, GitLab, Gitea/Forgejo/Codeberg, or Sourcehut)
34+
2. **Install required CLI tools** (if using GitHub or GitLab)
35+
3. **Authenticate** with your chosen platform
36+
4. **Configure access tokens** (if using Gitea/Forgejo/Codeberg or Sourcehut)
4537

46-
You should see: `✓ Logged in to github.com as YOUR_USERNAME`
38+
The setup process will provide helpful error messages and installation instructions if anything is missing.
4739

4840
## Installing `gitfetch`
4941

@@ -165,107 +157,47 @@ gh auth status
165157

166158
Configuration file location: `~/.config/gitfetch/gitfetch.conf`
167159

168-
The configuration file is automatically created on first run and contains two main sections:
160+
The configuration file is automatically created on first run. See `docs/providers.md` for detailed provider configuration and `docs/colors.md` for color customization options.
169161

170162
### [DEFAULT] Section
171163

172164
```ini
173165
[DEFAULT]
174166
username = yourusername
175167
cache_expiry_hours = 24
168+
provider = github
169+
provider_url = https://api.github.com
176170
```
177171

178-
- `username`: Your default GitHub username (automatically set from authenticated GitHub CLI user)
172+
- `username`: Your default username (automatically detected)
179173
- `cache_expiry_hours`: How long to keep cached data (default: 24 hours)
174+
- `provider`: Git hosting provider (github, gitlab, gitea, sourcehut)
175+
- `provider_url`: API URL for the provider
180176

181177
### [COLORS] Section
182178

183-
gitfetch supports extensive color customization. All colors use ANSI escape codes.
179+
gitfetch supports extensive color customization. All colors use ANSI escape codes. See `docs/colors.md` for detailed color configuration options.
184180

181+
````ini
185182
```ini
186183
[COLORS]
187184
reset = \033[0m
188185
bold = \033[1m
189-
dim = \033[2m
190-
red = \033[91m
191-
green = \033[92m
192-
yellow = \033[93m
193-
blue = \033[94m
194-
magenta = \033[95m
195-
cyan = \033[96m
196-
white = \033[97m
197-
orange = \033[38;2;255;165;0m
198-
accent = \033[1m
199-
header = \033[38;2;118;215;161m
200-
muted = \033[2m
201-
0 = \033[48;5;238m
202-
1 = \033[48;5;28m
203-
2 = \033[48;5;34m
204-
3 = \033[48;5;40m
205-
4 = \033[48;5;82m
206-
```
207-
208-
#### Color Reference
209-
210-
- **Text Styles**:
211-
212-
- `reset`: Reset all formatting
213-
- `bold`: Bold text
214-
- `dim`: Dimmed text
215-
- `accent`: Accent styling (bold)
216-
217-
- **Basic Colors**:
218-
219-
- `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`: Standard ANSI colors
220-
- `orange`: Custom orange color
221-
222-
- **UI Elements**:
223-
224-
- `header`: Section headers and main display text
225-
- `muted`: Separators and underlines
226-
227-
- **Contribution Graph**:
228-
- `0`: No contributions (lightest)
229-
- `1`: 1-2 contributions
230-
- `2`: 3-6 contributions
231-
- `3`: 7-12 contributions
232-
- `4`: 13+ contributions (darkest)
233-
234-
#### Customizing Colors
235-
236-
To change colors, edit `~/.config/gitfetch/gitfetch.conf` and modify the ANSI escape codes:
237-
238-
**Example: Change header color to blue**
239-
240-
```ini
241-
header = \033[94m
242-
```
243-
244-
**Example: Change contribution graph colors to a purple theme**
245-
246-
```ini
247-
0 = \033[48;5;235m # Dark gray for no contributions
248-
1 = \033[48;5;60m # Dark purple
249-
2 = \033[48;5;62m # Medium purple
250-
3 = \033[48;5;64m # Light purple
251-
4 = \033[48;5;66m # Bright purple
252-
```
186+
# ... color definitions ...
187+
````
253188

254-
**Common ANSI Color Codes**:
189+
See `docs/colors.md` for detailed color configuration options and customization examples.
255190

256-
- `\033[91m` = Bright Red
257-
- `\033[92m` = Bright Green
258-
- `\033[93m` = Bright Yellow
259-
- `\033[94m` = Bright Blue
260-
- `\033[95m` = Bright Magenta
261-
- `\033[96m` = Bright Cyan
262-
- `\033[97m` = Bright White
191+
## Supported Providers
263192

264-
**Background Colors** (for contribution blocks):
193+
gitfetch supports multiple Git hosting platforms:
265194

266-
- `\033[48;5;{color_code}m` where color_code is 0-255 (256-color palette)
195+
- **GitHub** - Uses GitHub CLI (gh) for authentication
196+
- **GitLab** - Uses GitLab CLI (glab) for authentication
197+
- **Gitea/Forgejo/Codeberg** - Direct API access with personal access tokens
198+
- **Sourcehut** - Direct API access with personal access tokens
267199

268-
Changes take effect immediately - no restart required.
200+
See `docs/providers.md` for detailed setup instructions for each provider.
269201

270202
## Caching
271203

docs/colors.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Color Configuration
2+
3+
gitfetch uses ANSI color codes for terminal output. Colors can be customized in the `[COLORS]` section of the config file.
4+
5+
## Available Colors
6+
7+
The following color keys can be customized:
8+
9+
### Text Formatting
10+
11+
- `reset`: Reset all formatting
12+
- `bold`: Bold text
13+
- `dim`: Dimmed text
14+
15+
### Basic Colors
16+
17+
- `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
18+
19+
### Special Colors
20+
21+
- `orange`: Orange color
22+
- `accent`: Accent color for highlights
23+
- `header`: Header text color
24+
- `muted`: Muted text color
25+
26+
### Contribution Graph Colors (0-4)
27+
28+
- `0`: Lowest contribution level
29+
- `1`: Low contribution level
30+
- `2`: Medium contribution level
31+
- `3`: High contribution level
32+
- `4`: Highest contribution level
33+
34+
## Configuration
35+
36+
Colors use ANSI escape codes. Examples:
37+
38+
```ini
39+
[COLORS]
40+
reset = \033[0m
41+
bold = \033[1m
42+
red = \033[91m
43+
green = \033[92m
44+
blue = \033[94m
45+
header = \033[38;2;118;215;161m
46+
0 = \033[48;5;238m
47+
1 = \033[48;5;28m
48+
```
49+
50+
## ANSI Color Codes
51+
52+
- `\033[0m`: Reset
53+
- `\033[1m`: Bold
54+
- `\033[2m`: Dim
55+
- `\033[91m`: Bright Red
56+
- `\033[92m`: Bright Green
57+
- `\033[93m`: Bright Yellow
58+
- `\033[94m`: Bright Blue
59+
- `\033[95m`: Bright Magenta
60+
- `\033[96m`: Bright Cyan
61+
- `\033[97m`: Bright White
62+
63+
For 256-color codes, use `\033[38;5;{color_code}m` for foreground or `\033[48;5;{color_code}m` for background.
64+
65+
For RGB colors, use `\033[38;2;{r};{g};{b}m` for foreground or `\033[48;2;{r};{g};{b}m` for background.

docs/providers.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Git Providers
2+
3+
gitfetch supports multiple Git hosting providers. Configure your preferred provider in the config file.
4+
5+
## Supported Providers
6+
7+
### GitHub
8+
9+
- **provider**: `github`
10+
- **provider_url**: `https://api.github.com`
11+
- **Requirements**: GitHub CLI (`gh`) must be installed and authenticated
12+
- **Authentication**: Run `gh auth login`
13+
14+
### GitLab
15+
16+
- **provider**: `gitlab`
17+
- **provider_url**: `https://gitlab.com`
18+
- **Requirements**: GitLab CLI (`glab`) must be installed and authenticated
19+
- **Authentication**: Run `glab auth login`
20+
21+
### Gitea/Forgejo/Codeberg
22+
23+
- **provider**: `gitea`
24+
- **provider_url**: Custom URL (e.g., `https://codeberg.org`, `https://gitea.com`)
25+
- **Requirements**: None (uses API directly)
26+
- **Authentication**: Set personal access token in environment or use CLI tools
27+
28+
### Sourcehut
29+
30+
- **provider**: `sourcehut`
31+
- **provider_url**: `https://git.sr.ht`
32+
- **Requirements**: None (uses API directly)
33+
- **Authentication**: Set personal access token in environment
34+
35+
## Configuration
36+
37+
Set the provider and URL in your `gitfetch.conf`:
38+
39+
```ini
40+
[DEFAULT]
41+
provider = github
42+
provider_url = https://api.github.com
43+
```
44+
45+
## Adding New Providers
46+
47+
To add support for a new Git provider, implement a new fetcher class in `fetcher.py` and update the provider selection logic in `cli.py`.

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "gitfetch"
7-
version = "1.0.20"
7+
version = "1.1.0"
88
description = "A neofetch-style CLI tool for GitHub statistics"
99
readme = "README.md"
1010
requires-python = ">=3.8"
@@ -27,7 +27,8 @@ classifiers = [
2727
]
2828

2929
dependencies = [
30-
"requests>=2.0.0"
30+
"requests>=2.0.0",
31+
"readchar>=4.0.0"
3132
]
3233

3334
[project.optional-dependencies]
@@ -50,6 +51,9 @@ Issues = "https://github.com/Matars/gitfetch/issues"
5051
[tool.setuptools.packages.find]
5152
where = ["src"]
5253

54+
[tool.setuptools.package-data]
55+
gitfetch = ["docs/*.md"]
56+
5357
[tool.black]
5458
line-length = 100
5559
target-version = ['py38', 'py39', 'py310', 'py311']

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# No Python dependencies required
22
# Requires GitHub CLI (gh) to be installed and authenticated
33
requests>=2.0.0
4+
readchar>=4.0.0

0 commit comments

Comments
 (0)