Skip to content

Commit 0d3a774

Browse files
authored
Merge pull request #23 from Matars/MultipleProviders
Multiple providers
2 parents a3bccb8 + 895adad commit 0d3a774

9 files changed

Lines changed: 99 additions & 42 deletions

File tree

.github/workflows/update-aur.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,10 @@ jobs:
5454
# Update dependencies
5555
sed -i 's/depends=.*/depends=("python-requests" "python-readchar")/' PKGBUILD
5656
57-
- name: Update .SRCINFO
57+
- name: Regenerate .SRCINFO
5858
run: |
5959
cd aur-repo
60-
sed -i 's/pkgver = .*/pkgver = ${{ steps.get_version.outputs.version }}/' .SRCINFO
61-
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
62-
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
60+
makepkg --printsrcinfo > .SRCINFO
6561
6662
- name: Commit and push
6763
run: |

README.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,6 @@ See `docs/colors.md` for detailed color configuration options and customization
192192

193193
gitfetch supports multiple Git hosting platforms:
194194

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
199-
200195
See `docs/providers.md` for detailed setup instructions for each provider.
201196

202197
## Caching
@@ -212,16 +207,6 @@ If you have an older version of gitfetch that stored cache in `~/.config/gitfetc
212207
```bash
213208
rm ~/.config/gitfetch/cache.db
214209
```
215-
216-
## Why GitHub CLI?
217-
218-
Using the GitHub CLI (gh) instead of direct API calls provides several benefits:
219-
220-
-**No rate limits** - Uses your authenticated GitHub account
221-
-**Automatic authentication** - No need to manage tokens
222-
-**Better security** - Credentials managed by gh CLI
223-
-**Simpler setup** - Just run `gh auth login`
224-
225210
## Acknowledgements
226211

227212
- Inspired by the beautiful contribution graph design from [Kusa](https://github.com/Ryu0118/Kusa) by Ryu0118.

docs/colors.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,21 @@ The following color keys can be customized:
3333

3434
## Configuration
3535

36-
Colors use ANSI escape codes. Examples:
36+
Colors can be specified using either ANSI escape codes or color names. Examples:
37+
38+
### Using Color Names
39+
40+
```ini
41+
[COLORS]
42+
header = blue
43+
red = bright_red
44+
green = cyan
45+
yellow = orange
46+
muted = gray
47+
accent = magenta
48+
```
49+
50+
### Using ANSI Codes
3751

3852
```ini
3953
[COLORS]
@@ -47,6 +61,30 @@ header = \033[38;2;118;215;161m
4761
1 = \033[48;5;28m
4862
```
4963

64+
## Supported Color Names
65+
66+
The following color names can be used instead of ANSI codes:
67+
68+
- `black``\033[30m` (dark gray/black)
69+
- `red``\033[91m` (bright red)
70+
- `green``\033[92m` (bright green)
71+
- `yellow``\033[93m` (bright yellow)
72+
- `blue``\033[94m` (bright blue)
73+
- `magenta``\033[95m` (bright magenta)
74+
- `cyan``\033[96m` (bright cyan)
75+
- `white``\033[97m` (bright white)
76+
- `gray``\033[90m` (dim white/gray)
77+
- `bright_red``\033[91m` (same as red)
78+
- `bright_green``\033[92m` (same as green)
79+
- `bright_yellow``\033[93m` (same as yellow)
80+
- `bright_blue``\033[94m` (same as blue)
81+
- `bright_magenta``\033[95m` (same as magenta)
82+
- `bright_cyan``\033[96m` (same as cyan)
83+
- `bright_white``\033[97m` (same as white)
84+
- `orange``\033[38;2;255;165;0m` (true orange RGB)
85+
- `purple``\033[95m` (alias for magenta)
86+
- `pink``\033[95m` (alias for magenta)
87+
5088
## ANSI Color Codes
5189

5290
- `\033[0m`: Reset

pyproject.toml

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

55
[project]
66
name = "gitfetch"
7-
version = "1.1.0"
8-
description = "A neofetch-style CLI tool for GitHub statistics"
7+
version = "1.1.1"
8+
description = "A neofetch-style CLI tool for git provider statistics"
99
readme = "README.md"
1010
requires-python = ">=3.8"
1111
license = {text = "GPL-2.0"}

src/gitfetch/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
gitfetch - A neofetch-style CLI tool for GitHub statistics
2+
gitfetch - A neofetch-style CLI tool for git provider statistics
33
"""
44

55
import re
@@ -14,7 +14,7 @@ def _get_version() -> str:
1414
return metadata.version("gitfetch")
1515
except (ImportError, metadata.PackageNotFoundError):
1616
pass
17-
17+
1818
# Fallback: try to read from pyproject.toml (works in development)
1919
pyproject_path = Path(__file__).parent.parent.parent / "pyproject.toml"
2020
try:

src/gitfetch/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def parse_args() -> argparse.Namespace:
2424
parser.add_argument(
2525
"username",
2626
nargs="?",
27-
help="GitHub username to fetch stats for"
27+
help="Username to fetch stats for"
2828
)
2929

3030
parser.add_argument(

src/gitfetch/config.py

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _load_config(self) -> None:
6868

6969
def get_default_username(self) -> Optional[str]:
7070
"""
71-
Get the default GitHub username from config.
71+
Get the default username from config.
7272
7373
Returns:
7474
Default username or None if not set
@@ -83,14 +83,48 @@ def get_colors(self) -> dict:
8383
Returns:
8484
User defined colors or default colors if not set
8585
"""
86-
return self.config._sections["COLORS"]
86+
# Color name to ANSI code mapping
87+
color_names = {
88+
'black': '\\033[30m',
89+
'red': '\\033[91m',
90+
'green': '\\033[92m',
91+
'yellow': '\\033[93m',
92+
'blue': '\\033[94m',
93+
'magenta': '\\033[95m',
94+
'cyan': '\\033[96m',
95+
'white': '\\033[97m',
96+
'gray': '\\033[90m',
97+
'bright_red': '\\033[91m',
98+
'bright_green': '\\033[92m',
99+
'bright_yellow': '\\033[93m',
100+
'bright_blue': '\\033[94m',
101+
'bright_magenta': '\\033[95m',
102+
'bright_cyan': '\\033[96m',
103+
'bright_white': '\\033[97m',
104+
'orange': '\\033[38;2;255;165;0m',
105+
'purple': '\\033[95m', # alias for magenta
106+
'pink': '\\033[95m', # alias for magenta
107+
}
108+
109+
colors = self.config._sections["COLORS"]
110+
resolved_colors = {}
111+
112+
for key, value in colors.items():
113+
# If the value is a known color name, map it to ANSI code
114+
if value.lower() in color_names:
115+
resolved_colors[key] = color_names[value.lower()]
116+
else:
117+
# Assume it's already an ANSI code or keep as-is
118+
resolved_colors[key] = value
119+
120+
return resolved_colors
87121

88122
def set_default_username(self, username: str) -> None:
89123
"""
90-
Set the default GitHub username in config.
124+
Set the default username in config.
91125
92126
Args:
93-
username: GitHub username to set as default
127+
username: Username to set as default
94128
"""
95129
if 'DEFAULT' not in self.config:
96130
self.config['DEFAULT'] = {}
@@ -203,7 +237,11 @@ def save(self) -> None:
203237

204238
if 'COLORS' in self.config:
205239
f.write("[COLORS]\n")
206-
for key, value in self.config['COLORS'].items():
207-
f.write(f"{key} = {value}\n")
240+
# Find the longest key for alignment
241+
if self.config['COLORS']:
242+
keys = list(self.config['COLORS'].keys())
243+
max_key_length = max(len(key) for key in keys)
244+
for key, value in self.config['COLORS'].items():
245+
f.write(f"{key:<{max_key_length}} = {value}\n")
208246
f.write("\n")
209247
f.write("\n")

src/gitfetch/display.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Display formatter for GitHub statistics in neofetch style
2+
Display formatter for git provider statistics in neofetch style
33
"""
44

55
from typing import Dict, Any, Optional
@@ -12,7 +12,7 @@
1212

1313

1414
class DisplayFormatter:
15-
"""Formats and displays GitHub stats in a neofetch-style layout."""
15+
"""Formats and displays git provider stats in a neofetch-style layout."""
1616

1717
def __init__(self, config_manager: ConfigManager):
1818
"""Initialize the display formatter."""
@@ -23,10 +23,10 @@ def __init__(self, config_manager: ConfigManager):
2323
def display(self, username: str, user_data: Dict[str, Any],
2424
stats: Dict[str, Any], spaced=True) -> None:
2525
"""
26-
Display GitHub statistics in neofetch style.
26+
Display git provider statistics in neofetch style.
2727
2828
Args:
29-
username: GitHub username
29+
username: Git provider username
3030
user_data: User profile data
3131
stats: User statistics data
3232
spaced: Spaced layout
@@ -364,8 +364,8 @@ def _render_progress_bar(self, percentage: float,
364364
filled = min(filled, width)
365365
empty = width - filled
366366

367-
filled_segment = "" * filled
368-
empty_segment = "" * empty
367+
filled_segment = "" * filled
368+
empty_segment = "" * empty
369369

370370
if self.enable_color and filled_segment:
371371
filled_segment = self._colorize(filled_segment, 'green')
@@ -381,8 +381,8 @@ def _render_progress_bar_no_brackets(self, percentage: float,
381381
filled = min(filled, width)
382382
empty = width - filled
383383

384-
filled_segment = "" * filled
385-
empty_segment = "" * empty
384+
filled_segment = "" * filled
385+
empty_segment = "" * empty
386386

387387
if self.enable_color and filled_segment:
388388
filled_segment = self._colorize(filled_segment, 'green')

src/gitfetch/fetcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def _check_gh_cli(self) -> None:
100100

101101
def get_authenticated_user(self) -> str:
102102
"""
103-
Get the authenticated GitHub username.
103+
Get the authenticated username.
104104
105105
Returns:
106106
The login of the authenticated user

0 commit comments

Comments
 (0)