ghlang 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ghlang-2.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Mihai Bors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
ghlang-2.2.0/PKG-INFO ADDED
@@ -0,0 +1,383 @@
1
+ Metadata-Version: 2.4
2
+ Name: ghlang
3
+ Version: 2.2.0
4
+ Summary: Generate language statistics and visualizations from GitHub repositories or local files
5
+ Author-email: MihaiStreames <72852703+MihaiStreames@users.noreply.github.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/MihaiStreames/ghlang
8
+ Project-URL: Repository, https://github.com/MihaiStreames/ghlang
9
+ Project-URL: Issues, https://github.com/MihaiStreames/ghlang/issues
10
+ Keywords: github,statistics,visualization,code-analysis,developer-tools,charts,programming-languages,cloc,analytics,cli,metrics
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Quality Assurance
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: Utilities
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.10
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: requests>=2.32.5
29
+ Requires-Dist: matplotlib>=3.10.8
30
+ Requires-Dist: pillow>=12.0.0
31
+ Requires-Dist: pyyaml>=6.0.3
32
+ Requires-Dist: rich>=13.0.0
33
+ Requires-Dist: typer>=0.21.0
34
+ Provides-Extra: dev
35
+ Requires-Dist: types-requests>=2.32.4; extra == "dev"
36
+ Requires-Dist: types-PyYAML>=6.0.12; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ <a id="readme-top"></a>
40
+
41
+ <!-- PROJECT SHIELDS -->
42
+ <div align="center">
43
+
44
+ [![PyPI](https://img.shields.io/pypi/v/ghlang?label=PyPI)](https://pypi.org/project/ghlang/)
45
+ [![Python Version](https://img.shields.io/pypi/pyversions/ghlang?label=Python)](https://pypi.org/project/ghlang/)
46
+ [![Downloads](https://img.shields.io/pypi/dm/ghlang?label=Downloads)](https://pypi.org/project/ghlang/)
47
+ [![Stars](https://img.shields.io/github/stars/MihaiStreames/ghlang?style=social)](https://github.com/MihaiStreames/ghlang/stargazers)
48
+ [![License](https://img.shields.io/github/license/MihaiStreames/ghlang?label=License)](LICENSE)
49
+ [![Issues](https://img.shields.io/github/issues/MihaiStreames/ghlang?label=Issues)](https://github.com/MihaiStreames/ghlang/issues)
50
+
51
+ </div>
52
+
53
+ <!-- PROJECT LOGO -->
54
+ <div align="center">
55
+ <h1>ghlang</h1>
56
+
57
+ <h3 align="center">See what languages you've been coding in</h3>
58
+
59
+ <p align="center">
60
+ Generate pretty charts from your GitHub repos or local files
61
+ </p>
62
+ </div>
63
+
64
+ <!-- TABLE OF CONTENTS -->
65
+ <details>
66
+ <summary>Table of Contents</summary>
67
+ <ol>
68
+ <li>
69
+ <a href="#about-the-project">About The Project</a>
70
+ <ul>
71
+ <li><a href="#built-with">Built With</a></li>
72
+ </ul>
73
+ </li>
74
+ <li>
75
+ <a href="#getting-started">Getting Started</a>
76
+ <ul>
77
+ <li><a href="#prerequisites">Prerequisites</a></li>
78
+ <li><a href="#installation">Installation</a></li>
79
+ </ul>
80
+ </li>
81
+ <li><a href="#usage">Usage</a></li>
82
+ <li><a href="#shell-completion">Shell Completion</a></li>
83
+ <li><a href="#configuration">Configuration</a></li>
84
+ <li><a href="#output">Output</a></li>
85
+ <li><a href="#themes">Themes</a></li>
86
+ <li><a href="#license">License</a></li>
87
+ </ol>
88
+ </details>
89
+
90
+ <!-- ABOUT THE PROJECT -->
91
+ ## About The Project
92
+
93
+ Ever wondered what languages you actually use? **ghlang** makes pretty charts to show you:
94
+
95
+ - **GitHub mode**: Pulls stats from all your repos via the API (counts bytes)
96
+ - **Local mode**: Analyzes files on your machine using [cloc](https://github.com/AlDanial/cloc) (counts lines)
97
+
98
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
99
+
100
+ ### Built With
101
+
102
+ - [Python](https://www.python.org/)
103
+ - [Typer](https://typer.tiangolo.com/)
104
+ - [Matplotlib](https://matplotlib.org/)
105
+ - [Requests](https://requests.readthedocs.io/)
106
+ - [Rich](https://github.com/Textualize/rich)
107
+ - [cloc](https://github.com/AlDanial/cloc) (for local analysis)
108
+
109
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
110
+
111
+ <!-- GETTING STARTED -->
112
+ ## Getting Started
113
+
114
+ Getting this running is pretty straightforward.
115
+
116
+ ### What You'll Need
117
+
118
+ - Python 3.10+
119
+ - For GitHub mode: a GitHub token
120
+ - For local mode: [cloc](https://github.com/AlDanial/cloc)
121
+
122
+ ### Installation
123
+
124
+ ```bash
125
+ # with pipx (recommended)
126
+ pipx install ghlang
127
+
128
+ # or with pip
129
+ pip install ghlang
130
+
131
+ # or install from source
132
+ pip install git+https://github.com/MihaiStreames/ghlang.git
133
+ ```
134
+
135
+ For local mode, you'll also need cloc:
136
+
137
+ ```bash
138
+ # Arch
139
+ pacman -S cloc
140
+
141
+ # Ubuntu/Debian
142
+ apt install cloc
143
+
144
+ # macOS
145
+ brew install cloc
146
+
147
+ # Windows
148
+ choco install cloc
149
+ ```
150
+
151
+ ### Setting Up GitHub Mode
152
+
153
+ 1. **Get a token** from [GitHub Settings](https://github.com/settings/tokens)
154
+ - Pick `repo` for private repos, or just `public_repo` for public only
155
+
156
+ 2. **Run it once** to create the config file:
157
+
158
+ ```bash
159
+ ghlang github
160
+ ```
161
+
162
+ Config lives at `~/.config/ghlang/config.toml` (or `%LOCALAPPDATA%\ghlang\config.toml` on Windows)
163
+
164
+ 3. **Add your token** to the config:
165
+
166
+ ```toml
167
+ [github]
168
+ token = "ghp_your_token_here"
169
+ ```
170
+
171
+ 4. **Run it again** and you're good:
172
+
173
+ ```bash
174
+ ghlang github
175
+ ```
176
+
177
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
178
+
179
+ <!-- USAGE EXAMPLES -->
180
+ ## Usage
181
+
182
+ ### GitHub Mode
183
+
184
+ ```bash
185
+ # analyze all your repos
186
+ ghlang github
187
+ ```
188
+
189
+ ### Local Mode
190
+
191
+ ```bash
192
+ # analyze current directory
193
+ ghlang local
194
+
195
+ # analyze a specific path
196
+ ghlang local ~/projects/my-app
197
+ ```
198
+
199
+ ### Config Management
200
+
201
+ ```bash
202
+ # open config in your editor
203
+ ghlang config
204
+
205
+ # show config as formatted table
206
+ ghlang config --show
207
+
208
+ # print config file path
209
+ ghlang config --path
210
+
211
+ # print raw TOML contents
212
+ ghlang config --raw
213
+ ```
214
+
215
+ ### Other Options
216
+
217
+ ```bash
218
+ # more logging
219
+ ghlang github -v
220
+
221
+ # save charts somewhere else
222
+ ghlang github -o ~/my-stats
223
+
224
+ # show top 10 languages instead of 5
225
+ ghlang local --top-n 10
226
+
227
+ # pipe to jq
228
+ ghlang local ~/project --stdout | jq '.Python'
229
+
230
+ # get the top language
231
+ ghlang github --stdout | jq -r 'to_entries | sort_by(-.value) | .[0].key'
232
+ ```
233
+
234
+ ### All the Flags
235
+
236
+ Both `github` and `local` commands share the same options:
237
+
238
+ | Flag | Short | What it does |
239
+ |------|-------|--------------|
240
+ | `--config` | | use a different config file |
241
+ | `--output-dir` | | where to save the charts (directory) |
242
+ | `--output` | `-o` | custom output filename (creates `_pie` and `_bar` variants) |
243
+ | `--title` | `-t` | custom chart title |
244
+ | `--top-n` | | how many languages in the bar chart |
245
+ | `--theme` | | chart color theme (default: light) |
246
+ | `--format` | `-f` | output format, overrides `--output` extension (png or svg) |
247
+ | `--json-only` | | output JSON only, skip chart generation |
248
+ | `--stdout` | | output stats to stdout (implies `--json-only --quiet`) |
249
+ | `--quiet` | `-q` | suppress log output (only show errors) |
250
+ | `--verbose` | `-v` | show more details |
251
+
252
+ The `local` command also takes an optional `[PATH]` argument (defaults to `.`) and has one extra flag:
253
+
254
+ | Flag | What it does |
255
+ |------------------|-------------------------------------------|
256
+ | `--follow-links` | follow symlinks when analyzing (unix only) |
257
+
258
+ The `config` command has its own options:
259
+
260
+ | Flag | What it does |
261
+ |------|--------------|
262
+ | `--show` | print config as formatted table |
263
+ | `--path` | print config file path |
264
+ | `--raw` | print raw TOML contents |
265
+
266
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
267
+
268
+ <!-- SHELL COMPLETION -->
269
+ ## Shell Completion
270
+
271
+ ghlang has built-in shell completion. To enable it:
272
+
273
+ ```bash
274
+ # install completion for your shell
275
+ ghlang --install-completion
276
+
277
+ # or just view the completion script
278
+ ghlang --show-completion
279
+ ```
280
+
281
+ After installing, restart your shell or source your config file.
282
+
283
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
284
+
285
+ <!-- OUTPUT -->
286
+ ## What You Get
287
+
288
+ Charts end up in your output directory (`.png` by default, or `.svg` with `--format svg`):
289
+
290
+ | File | What it is |
291
+ |------|------------|
292
+ | `language_pie.png` | pie chart with all languages |
293
+ | `language_bar.png` | bar chart with top N languages |
294
+ | `language_stats.json` | raw stats (if `save_json` is on) |
295
+ | `cloc_stats.json` | detailed cloc output (local mode) |
296
+ | `repositories.json` | list of repos analyzed (GitHub mode) |
297
+ | `github_colors.json` | language colors from GitHub |
298
+
299
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
300
+
301
+ <!-- CONFIGURATION -->
302
+ ## Config Options
303
+
304
+ Everything lives in `config.toml`:
305
+
306
+ ### `[github]`
307
+
308
+ | Option | Default | What it does |
309
+ |--------|---------|--------------|
310
+ | `token` | - | your GitHub token |
311
+ | `affiliation` | `"owner,collaborator,organization_member"` | which repos to include |
312
+ | `visibility` | `"all"` | `all`, `public`, or `private` |
313
+ | `ignored_repos` | `[]` | repos to skip (e.g. `"org/*"`, `"https://github.com/user/repo"`) |
314
+
315
+ ### `[cloc]`
316
+
317
+ | Option | Default | What it does |
318
+ |--------|---------|--------------|
319
+ | `ignored_dirs` | `["node_modules", "vendor", ...]` | directories to skip |
320
+
321
+ ### `[output]`
322
+
323
+ | Option | Default | What it does |
324
+ |--------|---------|--------------|
325
+ | `directory` | `"~/Documents/ghlang-stats"` | where to save charts |
326
+ | `save_json` | `false` | save raw stats as JSON |
327
+ | `save_repos` | `false` | save repo list as JSON |
328
+ | `top_n_languages` | `5` | how many in the bar chart |
329
+
330
+ ### `[preferences]`
331
+
332
+ | Option | Default | What it does |
333
+ |--------|---------|--------------|
334
+ | `verbose` | `false` | more logging |
335
+ | `theme` | `"light"` | chart color theme |
336
+
337
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
338
+
339
+ <!-- THEMES -->
340
+ ## Themes
341
+
342
+ ghlang comes with built-in themes for your charts:
343
+
344
+ | Theme | Preview | Author |
345
+ |-------|---------|--------|
346
+ | `light` | ![light](assets/themes/light.png) | built-in |
347
+ | `dark` | ![dark](assets/themes/dark.png) | built-in |
348
+ | `monokai` | ![monokai](assets/themes/monokai.png) | built-in |
349
+
350
+ ```bash
351
+ # use dark theme
352
+ ghlang github --theme dark
353
+ ```
354
+
355
+ or set it in `config.toml`:
356
+
357
+ ```toml
358
+ [preferences]
359
+ theme = "dark"
360
+ ```
361
+
362
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
363
+
364
+ <!-- LICENSE -->
365
+ ## License
366
+
367
+ MIT. Do whatever you want with it. See [LICENSE](LICENSE) for more information.
368
+
369
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
370
+
371
+ ---
372
+
373
+ <div align="center">
374
+
375
+ ### 🌟 Found this cool?
376
+
377
+ If you like ghlang, consider giving it a star! It helps others discover the tool.
378
+
379
+ [![Star on GitHub](https://img.shields.io/github/stars/MihaiStreames/ghlang?style=social)](https://github.com/MihaiStreames/ghlang/stargazers)
380
+
381
+ <p>Made with ❤️</p>
382
+
383
+ </div>