bt-ghcli 0.3.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.
- bt_ghcli-0.3.0/PKG-INFO +15 -0
- bt_ghcli-0.3.0/README.md +216 -0
- bt_ghcli-0.3.0/bt_ghcli.egg-info/PKG-INFO +15 -0
- bt_ghcli-0.3.0/bt_ghcli.egg-info/SOURCES.txt +15 -0
- bt_ghcli-0.3.0/bt_ghcli.egg-info/dependency_links.txt +1 -0
- bt_ghcli-0.3.0/bt_ghcli.egg-info/entry_points.txt +3 -0
- bt_ghcli-0.3.0/bt_ghcli.egg-info/requires.txt +10 -0
- bt_ghcli-0.3.0/bt_ghcli.egg-info/top_level.txt +2 -0
- bt_ghcli-0.3.0/ghpr/__init__.py +38 -0
- bt_ghcli-0.3.0/ghpr/cli.py +542 -0
- bt_ghcli-0.3.0/ghsearch/__init__.py +37 -0
- bt_ghcli-0.3.0/ghsearch/cli.py +950 -0
- bt_ghcli-0.3.0/pyproject.toml +48 -0
- bt_ghcli-0.3.0/setup.cfg +4 -0
- bt_ghcli-0.3.0/setup.py +12 -0
- bt_ghcli-0.3.0/tests/test_ghpr.py +182 -0
- bt_ghcli-0.3.0/tests/test_ghsearch.py +364 -0
bt_ghcli-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bt-ghcli
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: CLI for interacting with the GitHub API
|
|
5
|
+
Author-email: Bert Tejeda <berttejeda@gmail.com>
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Requires-Dist: requests>=2.31.0
|
|
8
|
+
Requires-Dist: httpx>=0.26.0
|
|
9
|
+
Requires-Dist: PyYAML>=6.0.0
|
|
10
|
+
Requires-Dist: typer[all]>=0.9.0
|
|
11
|
+
Requires-Dist: bt-credmgr>=0.2.0
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
14
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
15
|
+
Requires-Dist: pytest-mock>=3.11.1; extra == "dev"
|
bt_ghcli-0.3.0/README.md
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# bt-ghcli
|
|
2
|
+
|
|
3
|
+
CLI for interacting with the GitHub / GitHub Enterprise API. Provides two tools:
|
|
4
|
+
|
|
5
|
+
- **`ghpr`** — Pull Request management (create, approve, comment)
|
|
6
|
+
- **`ghsearch`** — Search repositories, code, and commits
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install bt-ghcli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Or install from source:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
git clone https://github.com/berttejeda/bert.git-cli.git
|
|
18
|
+
cd bert.git-cli
|
|
19
|
+
pip install -e ".[dev]"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Authentication
|
|
23
|
+
|
|
24
|
+
Token resolution follows this precedence (first match wins):
|
|
25
|
+
|
|
26
|
+
1. `--token` CLI argument
|
|
27
|
+
2. Config file value
|
|
28
|
+
3. Environment variable
|
|
29
|
+
4. OS Keyring (via [bt-credmgr](https://github.com/berttejeda/bert.credmgr))
|
|
30
|
+
|
|
31
|
+
### Environment Variables
|
|
32
|
+
|
|
33
|
+
| Tool | Variables (checked in order) |
|
|
34
|
+
|------|------------------------------|
|
|
35
|
+
| `ghpr` | `GHPR_TOKEN` → `GHE_TOKEN` → `GITHUB_TOKEN` |
|
|
36
|
+
| `ghsearch` | `GHSEARCH_TOKEN` → `GITHUB_TOKEN` |
|
|
37
|
+
|
|
38
|
+
### OS Keyring
|
|
39
|
+
|
|
40
|
+
If no token is found via CLI, config, or environment, the tool queries the OS password manager using a single, namespaced key:
|
|
41
|
+
|
|
42
|
+
| Tool | Default keyring key |
|
|
43
|
+
|------|-------------------|
|
|
44
|
+
| `ghpr` | `GHPR_TOKEN` |
|
|
45
|
+
| `ghsearch` | `GHSEARCH_TOKEN` |
|
|
46
|
+
|
|
47
|
+
Override with `--password-manager-key` / `-PMK`:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Store a token in the OS keyring
|
|
51
|
+
credstore --name GHPR_TOKEN --password <your-token>
|
|
52
|
+
|
|
53
|
+
# Use a custom keyring key
|
|
54
|
+
ghpr create --password-manager-key MY_CUSTOM_KEY ...
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The key can also be set in the config file:
|
|
58
|
+
|
|
59
|
+
```yaml
|
|
60
|
+
ghpr:
|
|
61
|
+
password_manager_key: MY_CUSTOM_KEY
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## ghpr
|
|
65
|
+
|
|
66
|
+
GitHub / GitHub Enterprise Pull Request management.
|
|
67
|
+
|
|
68
|
+
### Create a Pull Request
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
ghpr create --title "Fix bug" --body "Fixes issue #42" --head feature-branch --base main
|
|
72
|
+
|
|
73
|
+
# Create a draft PR
|
|
74
|
+
ghpr create --title "WIP: Feature" --head feature --base main --draft
|
|
75
|
+
|
|
76
|
+
# With labels
|
|
77
|
+
ghpr create --title "Feature" --head feature --base main --label bug --label enhancement
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Approve a Pull Request
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
ghpr approve --pr-number 123
|
|
84
|
+
|
|
85
|
+
# With a comment
|
|
86
|
+
ghpr approve --pr-number 123 --comment "Looks good!"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Comment on a Pull Request
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Review comment
|
|
93
|
+
ghpr comment --pr-number 123 --comment "Great work!" --type review
|
|
94
|
+
|
|
95
|
+
# Conversational comment
|
|
96
|
+
ghpr comment --pr-number 123 --comment "Thanks for the PR!" --type issue
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Common Options
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
--config, -c Path to config file (default: ~/.ghpr.yml)
|
|
103
|
+
--api-base Override API base URL
|
|
104
|
+
--token, -t GitHub token for authentication
|
|
105
|
+
--owner, -o Repository owner/organization
|
|
106
|
+
--repo, -r Repository name
|
|
107
|
+
--proxy, -x SOCKS5h proxy address
|
|
108
|
+
--verify-tls Enable TLS verification (default: True)
|
|
109
|
+
--no-verify-tls Disable TLS verification
|
|
110
|
+
--password-manager-key, -PMK Override keyring key (default: GHPR_TOKEN)
|
|
111
|
+
--debug Show API request details and curl equivalent
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Config File (~/.ghpr.yml)
|
|
115
|
+
|
|
116
|
+
```yaml
|
|
117
|
+
ghpr:
|
|
118
|
+
api_base: https://api.github.com
|
|
119
|
+
token: ghp_xxxxxxxxxxxx
|
|
120
|
+
owner: my-org
|
|
121
|
+
repo: my-repo
|
|
122
|
+
proxy: socks5h://localhost:1080
|
|
123
|
+
verify_tls: true
|
|
124
|
+
password_manager_key: GHPR_TOKEN
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## ghsearch
|
|
128
|
+
|
|
129
|
+
GitHub / GitHub Enterprise search for repositories, code, and commits.
|
|
130
|
+
|
|
131
|
+
### Search Repositories
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Search by topic
|
|
135
|
+
ghsearch repos --query "topic:astro topic:template"
|
|
136
|
+
|
|
137
|
+
# Filter by stars and language
|
|
138
|
+
ghsearch repos --query "language:python" --min-stars 100 --sort-by stars
|
|
139
|
+
|
|
140
|
+
# Group by language, top 20
|
|
141
|
+
ghsearch repos --query "topic:cli" --group-by-language --top-n 20
|
|
142
|
+
|
|
143
|
+
# GitHub Enterprise
|
|
144
|
+
ghsearch repos --api-base "https://github.company.com/api/v3" --query "org:myorg"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Search Code
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
ghsearch code --query "import typer" --repo "owner/repo" --language python
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Search Commits
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Search commits
|
|
157
|
+
ghsearch commits --query "fix bug"
|
|
158
|
+
|
|
159
|
+
# Filter by author
|
|
160
|
+
ghsearch commits --query "refactor" --author "username"
|
|
161
|
+
|
|
162
|
+
# Repository statistics
|
|
163
|
+
ghsearch commits --query "fix" --stats
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Common Options
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
--config, -c Path to config file (default: ~/.ghsearch.yml)
|
|
170
|
+
--api-base Override API base URL
|
|
171
|
+
--token GitHub token for authentication
|
|
172
|
+
--query, -q Search query
|
|
173
|
+
--per-page Results per page (max 100)
|
|
174
|
+
--max-pages Maximum pages to fetch
|
|
175
|
+
--verify-tls Enable TLS verification (default: True)
|
|
176
|
+
--no-verify-tls Disable TLS verification
|
|
177
|
+
--password-manager-key, -PMK Override keyring key (default: GHSEARCH_TOKEN)
|
|
178
|
+
--debug Show API request details and curl equivalent
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Config File (~/.ghsearch.yml)
|
|
182
|
+
|
|
183
|
+
```yaml
|
|
184
|
+
repos:
|
|
185
|
+
api_base: https://api.github.com
|
|
186
|
+
token: ghp_xxxxxxxxxxxx
|
|
187
|
+
query: "topic:astro"
|
|
188
|
+
per_page: 50
|
|
189
|
+
max_pages: 3
|
|
190
|
+
min_stars: 10
|
|
191
|
+
sort_by: stars
|
|
192
|
+
sort_direction: desc
|
|
193
|
+
group_by_language: true
|
|
194
|
+
top_n: 20
|
|
195
|
+
password_manager_key: GHSEARCH_TOKEN
|
|
196
|
+
|
|
197
|
+
code:
|
|
198
|
+
query: "import typer"
|
|
199
|
+
repo: "owner/repo"
|
|
200
|
+
language: python
|
|
201
|
+
|
|
202
|
+
commits:
|
|
203
|
+
query: "fix"
|
|
204
|
+
author: "username"
|
|
205
|
+
stats: true
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Running Tests
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
pytest
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## License
|
|
215
|
+
|
|
216
|
+
MIT
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bt-ghcli
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: CLI for interacting with the GitHub API
|
|
5
|
+
Author-email: Bert Tejeda <berttejeda@gmail.com>
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Requires-Dist: requests>=2.31.0
|
|
8
|
+
Requires-Dist: httpx>=0.26.0
|
|
9
|
+
Requires-Dist: PyYAML>=6.0.0
|
|
10
|
+
Requires-Dist: typer[all]>=0.9.0
|
|
11
|
+
Requires-Dist: bt-credmgr>=0.2.0
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
14
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
15
|
+
Requires-Dist: pytest-mock>=3.11.1; extra == "dev"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
setup.py
|
|
4
|
+
bt_ghcli.egg-info/PKG-INFO
|
|
5
|
+
bt_ghcli.egg-info/SOURCES.txt
|
|
6
|
+
bt_ghcli.egg-info/dependency_links.txt
|
|
7
|
+
bt_ghcli.egg-info/entry_points.txt
|
|
8
|
+
bt_ghcli.egg-info/requires.txt
|
|
9
|
+
bt_ghcli.egg-info/top_level.txt
|
|
10
|
+
ghpr/__init__.py
|
|
11
|
+
ghpr/cli.py
|
|
12
|
+
ghsearch/__init__.py
|
|
13
|
+
ghsearch/cli.py
|
|
14
|
+
tests/test_ghpr.py
|
|
15
|
+
tests/test_ghsearch.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ghpr provides a GitHub/GitHub Enterprise Pull Request management CLI.
|
|
3
|
+
"""
|
|
4
|
+
from .cli import app
|
|
5
|
+
|
|
6
|
+
__all__ = ["app", "__version__"]
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
10
|
+
except ImportError:
|
|
11
|
+
# Python < 3.8
|
|
12
|
+
try:
|
|
13
|
+
from importlib_metadata import version, PackageNotFoundError
|
|
14
|
+
except ImportError:
|
|
15
|
+
PackageNotFoundError = Exception
|
|
16
|
+
def version(package_name):
|
|
17
|
+
raise PackageNotFoundError
|
|
18
|
+
|
|
19
|
+
try:
|
|
20
|
+
__version__ = version("bt-ghcli")
|
|
21
|
+
except (PackageNotFoundError, Exception):
|
|
22
|
+
# Package not installed, fall back to reading from pyproject.toml
|
|
23
|
+
import re
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
|
|
26
|
+
pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
|
|
27
|
+
if pyproject_path.exists():
|
|
28
|
+
content = pyproject_path.read_text(encoding="utf-8")
|
|
29
|
+
match = re.search(r'version\s*=\s*["\']([^"\']+)["\']', content)
|
|
30
|
+
if match:
|
|
31
|
+
__version__ = match.group(1)
|
|
32
|
+
else:
|
|
33
|
+
__version__ = "0.0.0"
|
|
34
|
+
else:
|
|
35
|
+
__version__ = "0.0.0"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|