codefetch-cli 1.2.1__tar.gz → 1.2.2__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.
- {codefetch_cli-1.2.1 → codefetch_cli-1.2.2}/LICENSE +21 -21
- {codefetch_cli-1.2.1/codefetch_cli.egg-info → codefetch_cli-1.2.2}/PKG-INFO +46 -63
- {codefetch_cli-1.2.1 → codefetch_cli-1.2.2}/README.md +45 -62
- {codefetch_cli-1.2.1 → codefetch_cli-1.2.2}/codefetch/__init__.py +1 -1
- {codefetch_cli-1.2.1 → codefetch_cli-1.2.2}/codefetch/cli.py +90 -57
- {codefetch_cli-1.2.1 → codefetch_cli-1.2.2/codefetch_cli.egg-info}/PKG-INFO +46 -63
- {codefetch_cli-1.2.1 → codefetch_cli-1.2.2}/pyproject.toml +1 -1
- {codefetch_cli-1.2.1 → codefetch_cli-1.2.2}/setup.py +1 -1
- {codefetch_cli-1.2.1 → codefetch_cli-1.2.2}/codefetch_cli.egg-info/SOURCES.txt +0 -0
- {codefetch_cli-1.2.1 → codefetch_cli-1.2.2}/codefetch_cli.egg-info/dependency_links.txt +0 -0
- {codefetch_cli-1.2.1 → codefetch_cli-1.2.2}/codefetch_cli.egg-info/entry_points.txt +0 -0
- {codefetch_cli-1.2.1 → codefetch_cli-1.2.2}/codefetch_cli.egg-info/top_level.txt +0 -0
- {codefetch_cli-1.2.1 → codefetch_cli-1.2.2}/setup.cfg +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 InzamamulQureshi
|
|
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.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codefetch-cli
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: Quickly fetch code files from GitHub repositories with simple commands
|
|
5
5
|
Home-page: https://github.com/InzamamulQureshi/Codefetch
|
|
6
6
|
Author: Inzamamul Qureshi
|
|
@@ -30,13 +30,13 @@ CodeFetch is a lightweight command-line utility designed to quickly inspect, pre
|
|
|
30
30
|
|
|
31
31
|
## Features
|
|
32
32
|
|
|
33
|
-
- **Any User & Repository**: Fetch files from any public GitHub repository using intuitive syntax (`codefetch <
|
|
33
|
+
- **Any User & Repository**: Fetch files from any public GitHub repository using intuitive syntax (`codefetch <owner>/<repo> <filename>`).
|
|
34
34
|
- **Terminal Preview**: Inspect code directly in your console with `--show` without saving it to disk.
|
|
35
|
-
- **Automatic Path & Case Resolution**: Automatically resolves case mismatches
|
|
35
|
+
- **Automatic Path & Case Resolution**: Automatically resolves case mismatches and finds files nested inside subdirectories.
|
|
36
36
|
- **Repository Discovery**: List all public repositories for any GitHub user with `--repos`.
|
|
37
37
|
- **Tree Exploration**: List all supported code files within a repository with `--list`.
|
|
38
|
-
- **Persistent Defaults**:
|
|
39
|
-
- **
|
|
38
|
+
- **Optional Persistent Defaults**: Save a default repository or user with `--set-default` if you frequently work with the same repository.
|
|
39
|
+
- **Zero Runtime Dependencies**: Built using only the Python standard library with zero third-party dependencies.
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
@@ -70,80 +70,61 @@ pip install .
|
|
|
70
70
|
|
|
71
71
|
### 1. Download Files
|
|
72
72
|
|
|
73
|
-
Fetch a file from any GitHub repository:
|
|
73
|
+
Fetch a single file from any GitHub repository:
|
|
74
74
|
|
|
75
75
|
```bash
|
|
76
|
-
# Fetch from
|
|
77
|
-
codefetch
|
|
76
|
+
# Fetch a file from any user and repository
|
|
77
|
+
codefetch owner/repo main.py
|
|
78
78
|
|
|
79
|
-
#
|
|
80
|
-
codefetch
|
|
79
|
+
# Download a configuration or dataset
|
|
80
|
+
codefetch owner/repo data.csv
|
|
81
|
+
codefetch owner/repo config.yaml
|
|
81
82
|
|
|
82
|
-
#
|
|
83
|
-
codefetch
|
|
84
|
-
codefetch -r DS EXP1.c
|
|
83
|
+
# Download using explicit flags
|
|
84
|
+
codefetch -u owner -r repo main.py
|
|
85
85
|
|
|
86
|
-
#
|
|
87
|
-
codefetch
|
|
88
|
-
|
|
89
|
-
# Fetch from the default repository
|
|
90
|
-
codefetch 8.1.py
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Save to a custom filename or directory using `-o` / `--output`:
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
codefetch -r DS EXP1.c -o my_experiment.c
|
|
86
|
+
# Save with a custom filename or destination path
|
|
87
|
+
codefetch owner/repo main.py -o custom_name.py
|
|
97
88
|
```
|
|
98
89
|
|
|
99
90
|
### 2. Preview in Terminal (Without Downloading)
|
|
100
91
|
|
|
101
|
-
Display the contents of a file directly in stdout
|
|
92
|
+
Display the contents of a file directly in stdout with `-s` / `--show`:
|
|
102
93
|
|
|
103
94
|
```bash
|
|
104
|
-
# Preview file
|
|
105
|
-
codefetch
|
|
106
|
-
|
|
107
|
-
# Preview file from another repository
|
|
108
|
-
codefetch --show DS/EXP1.c
|
|
109
|
-
|
|
110
|
-
# Preview file from any user repository
|
|
111
|
-
codefetch --show InzamamulQureshi/Codefetch setup.py
|
|
95
|
+
# Preview file content in terminal
|
|
96
|
+
codefetch -s owner/repo main.py
|
|
97
|
+
codefetch -s torvalds/linux Makefile
|
|
112
98
|
```
|
|
113
99
|
|
|
114
100
|
### 3. Explore Repositories and Files
|
|
115
101
|
|
|
116
102
|
```bash
|
|
117
|
-
# List all
|
|
118
|
-
codefetch
|
|
119
|
-
|
|
120
|
-
# List all public repositories for a specific user
|
|
121
|
-
codefetch --repos -u InzamamulQureshi
|
|
122
|
-
codefetch --repos torvalds
|
|
103
|
+
# List all code files in a repository
|
|
104
|
+
codefetch -l owner/repo
|
|
105
|
+
codefetch --list owner/repo
|
|
123
106
|
|
|
124
|
-
# List
|
|
125
|
-
codefetch
|
|
126
|
-
|
|
127
|
-
# List code files in another repository
|
|
128
|
-
codefetch -r DS --list
|
|
129
|
-
codefetch --list InzamamulQureshi/Codefetch
|
|
107
|
+
# List all public repositories for any GitHub user
|
|
108
|
+
codefetch -R -u username
|
|
109
|
+
codefetch --repos username
|
|
130
110
|
```
|
|
131
111
|
|
|
132
|
-
### 4. Configuration and Defaults
|
|
112
|
+
### 4. Configuration and Defaults (Optional)
|
|
133
113
|
|
|
134
|
-
|
|
114
|
+
By default, CodeFetch has no preset repository or user. If you frequently fetch files from the same repository, you can optionally configure defaults:
|
|
135
115
|
|
|
136
116
|
```bash
|
|
137
|
-
# Set default repository
|
|
138
|
-
codefetch --set-default
|
|
117
|
+
# Set a default repository (saves both user and repo)
|
|
118
|
+
codefetch --set-default owner/repo
|
|
139
119
|
|
|
140
|
-
#
|
|
141
|
-
codefetch
|
|
120
|
+
# Now you can fetch files directly without typing the repo name!
|
|
121
|
+
codefetch main.py
|
|
122
|
+
codefetch -l
|
|
142
123
|
|
|
143
|
-
# View current configuration
|
|
124
|
+
# View current saved configuration
|
|
144
125
|
codefetch --config
|
|
145
126
|
|
|
146
|
-
# Reset configuration back to
|
|
127
|
+
# Reset all configuration back to defaults (no default repository)
|
|
147
128
|
codefetch --reset-config
|
|
148
129
|
```
|
|
149
130
|
|
|
@@ -153,17 +134,17 @@ codefetch --reset-config
|
|
|
153
134
|
|
|
154
135
|
| Flag | Description | Example |
|
|
155
136
|
|---|---|---|
|
|
156
|
-
| `-
|
|
157
|
-
| `-
|
|
158
|
-
| `-
|
|
159
|
-
| `-
|
|
160
|
-
| `-
|
|
161
|
-
| `-
|
|
162
|
-
| `-
|
|
163
|
-
| `--set-default` | Set persistent default repository | `codefetch --set-default
|
|
164
|
-
| `--set-default-user` | Set persistent default user | `codefetch --set-default-user
|
|
137
|
+
| `-s`, `--show` | Print file contents to terminal | `codefetch -s owner/repo main.py` |
|
|
138
|
+
| `-o`, `--output` | Specify destination output filename | `codefetch owner/repo main.py -o script.py` |
|
|
139
|
+
| `-l`, `--list` | List available code files in a repository | `codefetch -l owner/repo` |
|
|
140
|
+
| `-R`, `--repos` | List public repositories for a user | `codefetch -R -u username` |
|
|
141
|
+
| `-r`, `--repo` | Specify repository name or URL | `codefetch -r repo main.py` |
|
|
142
|
+
| `-u`, `--user` | Specify GitHub username or organization | `codefetch -u username -r repo main.py` |
|
|
143
|
+
| `-b`, `--branch` | Branch name (default: `main`) | `codefetch -b master owner/repo Makefile` |
|
|
144
|
+
| `--set-default` | Set persistent default repository | `codefetch --set-default owner/repo` |
|
|
145
|
+
| `--set-default-user` | Set persistent default user | `codefetch --set-default-user username` |
|
|
165
146
|
| `--config` | Display active configuration | `codefetch --config` |
|
|
166
|
-
| `--reset-config` | Reset configuration to defaults | `codefetch --reset-config` |
|
|
147
|
+
| `--reset-config` | Reset configuration back to defaults | `codefetch --reset-config` |
|
|
167
148
|
| `-v`, `--version` | Display version information | `codefetch --version` |
|
|
168
149
|
| `-h`, `--help` | Display help and usage message | `codefetch --help` |
|
|
169
150
|
|
|
@@ -171,6 +152,8 @@ codefetch --reset-config
|
|
|
171
152
|
|
|
172
153
|
## Supported File Extensions
|
|
173
154
|
|
|
155
|
+
CodeFetch recognizes and lists common source and document files:
|
|
156
|
+
|
|
174
157
|
- **Data & Tables**: `.csv`, `.tsv`, `.json`, `.jsonl`, `.yaml`, `.yml`, `.toml`, `.xml`, `.ini`, `.cfg`, `.conf`, `.env`
|
|
175
158
|
- **Data Science**: `.ipynb`, `.py`, `.r`, `.rmd`, `.m`
|
|
176
159
|
- **Languages**: `.c`, `.cpp`, `.h`, `.hpp`, `.rs`, `.go`, `.java`, `.kt`, `.cs`, `.swift`, `.dart`, `.php`
|
|
@@ -8,13 +8,13 @@ CodeFetch is a lightweight command-line utility designed to quickly inspect, pre
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
- **Any User & Repository**: Fetch files from any public GitHub repository using intuitive syntax (`codefetch <
|
|
11
|
+
- **Any User & Repository**: Fetch files from any public GitHub repository using intuitive syntax (`codefetch <owner>/<repo> <filename>`).
|
|
12
12
|
- **Terminal Preview**: Inspect code directly in your console with `--show` without saving it to disk.
|
|
13
|
-
- **Automatic Path & Case Resolution**: Automatically resolves case mismatches
|
|
13
|
+
- **Automatic Path & Case Resolution**: Automatically resolves case mismatches and finds files nested inside subdirectories.
|
|
14
14
|
- **Repository Discovery**: List all public repositories for any GitHub user with `--repos`.
|
|
15
15
|
- **Tree Exploration**: List all supported code files within a repository with `--list`.
|
|
16
|
-
- **Persistent Defaults**:
|
|
17
|
-
- **
|
|
16
|
+
- **Optional Persistent Defaults**: Save a default repository or user with `--set-default` if you frequently work with the same repository.
|
|
17
|
+
- **Zero Runtime Dependencies**: Built using only the Python standard library with zero third-party dependencies.
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
@@ -48,80 +48,61 @@ pip install .
|
|
|
48
48
|
|
|
49
49
|
### 1. Download Files
|
|
50
50
|
|
|
51
|
-
Fetch a file from any GitHub repository:
|
|
51
|
+
Fetch a single file from any GitHub repository:
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
|
-
# Fetch from
|
|
55
|
-
codefetch
|
|
54
|
+
# Fetch a file from any user and repository
|
|
55
|
+
codefetch owner/repo main.py
|
|
56
56
|
|
|
57
|
-
#
|
|
58
|
-
codefetch
|
|
57
|
+
# Download a configuration or dataset
|
|
58
|
+
codefetch owner/repo data.csv
|
|
59
|
+
codefetch owner/repo config.yaml
|
|
59
60
|
|
|
60
|
-
#
|
|
61
|
-
codefetch
|
|
62
|
-
codefetch -r DS EXP1.c
|
|
61
|
+
# Download using explicit flags
|
|
62
|
+
codefetch -u owner -r repo main.py
|
|
63
63
|
|
|
64
|
-
#
|
|
65
|
-
codefetch
|
|
66
|
-
|
|
67
|
-
# Fetch from the default repository
|
|
68
|
-
codefetch 8.1.py
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Save to a custom filename or directory using `-o` / `--output`:
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
codefetch -r DS EXP1.c -o my_experiment.c
|
|
64
|
+
# Save with a custom filename or destination path
|
|
65
|
+
codefetch owner/repo main.py -o custom_name.py
|
|
75
66
|
```
|
|
76
67
|
|
|
77
68
|
### 2. Preview in Terminal (Without Downloading)
|
|
78
69
|
|
|
79
|
-
Display the contents of a file directly in stdout
|
|
70
|
+
Display the contents of a file directly in stdout with `-s` / `--show`:
|
|
80
71
|
|
|
81
72
|
```bash
|
|
82
|
-
# Preview file
|
|
83
|
-
codefetch
|
|
84
|
-
|
|
85
|
-
# Preview file from another repository
|
|
86
|
-
codefetch --show DS/EXP1.c
|
|
87
|
-
|
|
88
|
-
# Preview file from any user repository
|
|
89
|
-
codefetch --show InzamamulQureshi/Codefetch setup.py
|
|
73
|
+
# Preview file content in terminal
|
|
74
|
+
codefetch -s owner/repo main.py
|
|
75
|
+
codefetch -s torvalds/linux Makefile
|
|
90
76
|
```
|
|
91
77
|
|
|
92
78
|
### 3. Explore Repositories and Files
|
|
93
79
|
|
|
94
80
|
```bash
|
|
95
|
-
# List all
|
|
96
|
-
codefetch
|
|
97
|
-
|
|
98
|
-
# List all public repositories for a specific user
|
|
99
|
-
codefetch --repos -u InzamamulQureshi
|
|
100
|
-
codefetch --repos torvalds
|
|
81
|
+
# List all code files in a repository
|
|
82
|
+
codefetch -l owner/repo
|
|
83
|
+
codefetch --list owner/repo
|
|
101
84
|
|
|
102
|
-
# List
|
|
103
|
-
codefetch
|
|
104
|
-
|
|
105
|
-
# List code files in another repository
|
|
106
|
-
codefetch -r DS --list
|
|
107
|
-
codefetch --list InzamamulQureshi/Codefetch
|
|
85
|
+
# List all public repositories for any GitHub user
|
|
86
|
+
codefetch -R -u username
|
|
87
|
+
codefetch --repos username
|
|
108
88
|
```
|
|
109
89
|
|
|
110
|
-
### 4. Configuration and Defaults
|
|
90
|
+
### 4. Configuration and Defaults (Optional)
|
|
111
91
|
|
|
112
|
-
|
|
92
|
+
By default, CodeFetch has no preset repository or user. If you frequently fetch files from the same repository, you can optionally configure defaults:
|
|
113
93
|
|
|
114
94
|
```bash
|
|
115
|
-
# Set default repository
|
|
116
|
-
codefetch --set-default
|
|
95
|
+
# Set a default repository (saves both user and repo)
|
|
96
|
+
codefetch --set-default owner/repo
|
|
117
97
|
|
|
118
|
-
#
|
|
119
|
-
codefetch
|
|
98
|
+
# Now you can fetch files directly without typing the repo name!
|
|
99
|
+
codefetch main.py
|
|
100
|
+
codefetch -l
|
|
120
101
|
|
|
121
|
-
# View current configuration
|
|
102
|
+
# View current saved configuration
|
|
122
103
|
codefetch --config
|
|
123
104
|
|
|
124
|
-
# Reset configuration back to
|
|
105
|
+
# Reset all configuration back to defaults (no default repository)
|
|
125
106
|
codefetch --reset-config
|
|
126
107
|
```
|
|
127
108
|
|
|
@@ -131,17 +112,17 @@ codefetch --reset-config
|
|
|
131
112
|
|
|
132
113
|
| Flag | Description | Example |
|
|
133
114
|
|---|---|---|
|
|
134
|
-
| `-
|
|
135
|
-
| `-
|
|
136
|
-
| `-
|
|
137
|
-
| `-
|
|
138
|
-
| `-
|
|
139
|
-
| `-
|
|
140
|
-
| `-
|
|
141
|
-
| `--set-default` | Set persistent default repository | `codefetch --set-default
|
|
142
|
-
| `--set-default-user` | Set persistent default user | `codefetch --set-default-user
|
|
115
|
+
| `-s`, `--show` | Print file contents to terminal | `codefetch -s owner/repo main.py` |
|
|
116
|
+
| `-o`, `--output` | Specify destination output filename | `codefetch owner/repo main.py -o script.py` |
|
|
117
|
+
| `-l`, `--list` | List available code files in a repository | `codefetch -l owner/repo` |
|
|
118
|
+
| `-R`, `--repos` | List public repositories for a user | `codefetch -R -u username` |
|
|
119
|
+
| `-r`, `--repo` | Specify repository name or URL | `codefetch -r repo main.py` |
|
|
120
|
+
| `-u`, `--user` | Specify GitHub username or organization | `codefetch -u username -r repo main.py` |
|
|
121
|
+
| `-b`, `--branch` | Branch name (default: `main`) | `codefetch -b master owner/repo Makefile` |
|
|
122
|
+
| `--set-default` | Set persistent default repository | `codefetch --set-default owner/repo` |
|
|
123
|
+
| `--set-default-user` | Set persistent default user | `codefetch --set-default-user username` |
|
|
143
124
|
| `--config` | Display active configuration | `codefetch --config` |
|
|
144
|
-
| `--reset-config` | Reset configuration to defaults | `codefetch --reset-config` |
|
|
125
|
+
| `--reset-config` | Reset configuration back to defaults | `codefetch --reset-config` |
|
|
145
126
|
| `-v`, `--version` | Display version information | `codefetch --version` |
|
|
146
127
|
| `-h`, `--help` | Display help and usage message | `codefetch --help` |
|
|
147
128
|
|
|
@@ -149,6 +130,8 @@ codefetch --reset-config
|
|
|
149
130
|
|
|
150
131
|
## Supported File Extensions
|
|
151
132
|
|
|
133
|
+
CodeFetch recognizes and lists common source and document files:
|
|
134
|
+
|
|
152
135
|
- **Data & Tables**: `.csv`, `.tsv`, `.json`, `.jsonl`, `.yaml`, `.yml`, `.toml`, `.xml`, `.ini`, `.cfg`, `.conf`, `.env`
|
|
153
136
|
- **Data Science**: `.ipynb`, `.py`, `.r`, `.rmd`, `.m`
|
|
154
137
|
- **Languages**: `.c`, `.cpp`, `.h`, `.hpp`, `.rs`, `.go`, `.java`, `.kt`, `.cs`, `.swift`, `.dart`, `.php`
|
|
@@ -12,8 +12,8 @@ import urllib.error
|
|
|
12
12
|
import urllib.request
|
|
13
13
|
from pathlib import Path
|
|
14
14
|
|
|
15
|
-
DEFAULT_OWNER =
|
|
16
|
-
DEFAULT_REPO =
|
|
15
|
+
DEFAULT_OWNER = None
|
|
16
|
+
DEFAULT_REPO = None
|
|
17
17
|
DEFAULT_BRANCH = "main"
|
|
18
18
|
|
|
19
19
|
CONFIG_FILE = Path.home() / ".codefetch.json"
|
|
@@ -55,42 +55,37 @@ HELP_MESSAGE = """\
|
|
|
55
55
|
CodeFetch - Download single code files from GitHub without cloning entire repos.
|
|
56
56
|
|
|
57
57
|
USAGE:
|
|
58
|
-
codefetch <filename>
|
|
59
|
-
codefetch <
|
|
60
|
-
codefetch <user>/<repo> <filename> Download from any GitHub user/repo
|
|
58
|
+
codefetch <owner>/<repo> <filename> Download a file from any GitHub repository
|
|
59
|
+
codefetch <filename> Download a file (requires default repository)
|
|
61
60
|
|
|
62
61
|
QUICK EXAMPLES:
|
|
63
62
|
Download a file:
|
|
64
|
-
codefetch
|
|
65
|
-
codefetch
|
|
66
|
-
codefetch
|
|
67
|
-
codefetch DS EXP1.c -o my_code.c Save with a custom output filename
|
|
68
|
-
codefetch InzamamulQureshi/Codefetch setup.py
|
|
63
|
+
codefetch torvalds/linux Makefile Save Makefile to current directory
|
|
64
|
+
codefetch owner/repo main.py Save main.py from a repository
|
|
65
|
+
codefetch owner/repo data.csv -o out.csv Save with a custom output filename
|
|
69
66
|
|
|
70
67
|
View code in terminal (without downloading):
|
|
71
|
-
codefetch -s
|
|
72
|
-
codefetch -s
|
|
68
|
+
codefetch -s owner/repo main.py Display main.py in terminal
|
|
69
|
+
codefetch -s torvalds/linux Makefile Display Makefile in terminal
|
|
73
70
|
|
|
74
71
|
Browse files and repositories:
|
|
75
|
-
codefetch -l
|
|
76
|
-
codefetch -
|
|
77
|
-
codefetch -
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
codefetch --
|
|
83
|
-
codefetch --
|
|
84
|
-
codefetch --config View current active settings
|
|
85
|
-
codefetch --reset-config Reset all settings back to default
|
|
72
|
+
codefetch -l owner/repo List all code files in a repository
|
|
73
|
+
codefetch -R -u <username> List all public repositories of a user
|
|
74
|
+
codefetch -R <username> List all public repositories of a user
|
|
75
|
+
|
|
76
|
+
SETTINGS & DEFAULTS (Optional):
|
|
77
|
+
codefetch --set-default <owner/repo> Set a permanent default repository
|
|
78
|
+
codefetch --set-default-user <username> Set a permanent default GitHub user
|
|
79
|
+
codefetch --config View current saved settings
|
|
80
|
+
codefetch --reset-config Clear saved settings
|
|
86
81
|
|
|
87
82
|
OPTIONS:
|
|
88
83
|
-s, --show View file contents in terminal instead of saving
|
|
89
84
|
-o, --output <file> Custom filename or path to save the downloaded file
|
|
90
|
-
-l, --list
|
|
91
|
-
-R, --repos
|
|
85
|
+
-l, --list [repo] List available code files in a repository
|
|
86
|
+
-R, --repos [user] List all public repositories for a user
|
|
92
87
|
-r, --repo <name> Specify repository name or URL
|
|
93
|
-
-u, --user <name> Specify GitHub username
|
|
88
|
+
-u, --user <name> Specify GitHub username
|
|
94
89
|
-b, --branch <name> Specify branch name (default: main)
|
|
95
90
|
-v, --version Show version number
|
|
96
91
|
-h, --help Show this help guide
|
|
@@ -157,7 +152,7 @@ def get_json(url):
|
|
|
157
152
|
return json.loads(response.read().decode("utf-8"))
|
|
158
153
|
|
|
159
154
|
|
|
160
|
-
def parse_repo_identifier(repo_str, default_owner=
|
|
155
|
+
def parse_repo_identifier(repo_str, default_owner=None):
|
|
161
156
|
"""Extract (owner, repo) from a repository flag, name, or URL."""
|
|
162
157
|
if not repo_str:
|
|
163
158
|
return default_owner, None
|
|
@@ -199,8 +194,15 @@ def get_user_repos(owner):
|
|
|
199
194
|
return []
|
|
200
195
|
|
|
201
196
|
|
|
202
|
-
def list_repos(owner=
|
|
197
|
+
def list_repos(owner=None, default_repo=None):
|
|
203
198
|
"""List all public repositories for the owner."""
|
|
199
|
+
if not owner:
|
|
200
|
+
print("Error: No GitHub user specified.\n")
|
|
201
|
+
print("Usage:")
|
|
202
|
+
print(" codefetch -R <username>")
|
|
203
|
+
print(" codefetch -R -u <username>")
|
|
204
|
+
return
|
|
205
|
+
|
|
204
206
|
try:
|
|
205
207
|
repos = get_user_repos(owner)
|
|
206
208
|
if not repos:
|
|
@@ -211,15 +213,15 @@ def list_repos(owner=DEFAULT_OWNER, default_repo=DEFAULT_REPO):
|
|
|
211
213
|
for r in repos:
|
|
212
214
|
name = r.get("name", "")
|
|
213
215
|
desc = r.get("description") or ""
|
|
214
|
-
is_def = " (default)" if name.lower() == default_repo.lower() else ""
|
|
216
|
+
is_def = " (default)" if default_repo and name.lower() == default_repo.lower() else ""
|
|
215
217
|
marker = "*" if is_def else "-"
|
|
216
218
|
desc_text = f" - {desc}" if desc else ""
|
|
217
219
|
print(f" {marker} {name}{is_def}{desc_text}")
|
|
218
220
|
|
|
219
221
|
print("\nCommands:")
|
|
220
|
-
print(f" codefetch -
|
|
221
|
-
print(f" codefetch
|
|
222
|
-
print(f" codefetch --set-default
|
|
222
|
+
print(f" codefetch -l {owner}/<repo> List files in a repository")
|
|
223
|
+
print(f" codefetch {owner}/<repo> <filename> Download a file from a repository")
|
|
224
|
+
print(f" codefetch --set-default {owner}/<repo> Set default repository")
|
|
223
225
|
|
|
224
226
|
except urllib.error.HTTPError as e:
|
|
225
227
|
print(f"Could not list repositories: HTTP {e.code}")
|
|
@@ -231,6 +233,13 @@ def list_repos(owner=DEFAULT_OWNER, default_repo=DEFAULT_REPO):
|
|
|
231
233
|
|
|
232
234
|
def list_files(owner, repo, branch="main"):
|
|
233
235
|
"""List code files in a repository."""
|
|
236
|
+
if not owner or not repo:
|
|
237
|
+
print("Error: No repository specified to list.\n")
|
|
238
|
+
print("Usage:")
|
|
239
|
+
print(" codefetch -l <owner>/<repo>")
|
|
240
|
+
print(" codefetch -u <owner> -r <repo> -l")
|
|
241
|
+
return
|
|
242
|
+
|
|
234
243
|
try:
|
|
235
244
|
data = get_repo_tree(owner, repo, branch)
|
|
236
245
|
if data.get("truncated"):
|
|
@@ -284,7 +293,7 @@ def resolve_file_in_tree(tree_data, target_filename):
|
|
|
284
293
|
Search tree for target_filename:
|
|
285
294
|
1. Exact match (case-insensitive) on full path
|
|
286
295
|
2. Exact match (case-insensitive) on basename
|
|
287
|
-
3. Match without extension (e.g. '
|
|
296
|
+
3. Match without extension (e.g. 'main' -> 'main.py')
|
|
288
297
|
"""
|
|
289
298
|
blobs = [item["path"] for item in tree_data.get("tree", []) if item.get("type") == "blob"]
|
|
290
299
|
target_clean = target_filename.strip("/\\").lower()
|
|
@@ -318,11 +327,13 @@ def resolve_file_in_tree(tree_data, target_filename):
|
|
|
318
327
|
|
|
319
328
|
def find_file_in_other_repos(owner, current_repo, target_filename):
|
|
320
329
|
"""Search other public repositories of the user for the target file."""
|
|
330
|
+
if not owner:
|
|
331
|
+
return None, None
|
|
321
332
|
try:
|
|
322
333
|
repos_data = get_user_repos(owner)
|
|
323
334
|
for r in repos_data:
|
|
324
335
|
r_name = r.get("name")
|
|
325
|
-
if not r_name or r_name.lower() == current_repo.lower():
|
|
336
|
+
if not r_name or (current_repo and r_name.lower() == current_repo.lower()):
|
|
326
337
|
continue
|
|
327
338
|
default_branch = r.get("default_branch", "main")
|
|
328
339
|
try:
|
|
@@ -337,9 +348,19 @@ def find_file_in_other_repos(owner, current_repo, target_filename):
|
|
|
337
348
|
return None, None
|
|
338
349
|
|
|
339
350
|
|
|
340
|
-
def fetch_file(filename, owner=
|
|
351
|
+
def fetch_file(filename, owner=None, repo=None, branch=DEFAULT_BRANCH,
|
|
341
352
|
show=False, output=None):
|
|
342
353
|
"""Fetch or download a file from GitHub."""
|
|
354
|
+
if not owner or not repo:
|
|
355
|
+
print("Error: No GitHub repository specified.\n")
|
|
356
|
+
print("Usage:")
|
|
357
|
+
print(" codefetch <owner>/<repo> <filename>")
|
|
358
|
+
print(" codefetch -u <owner> -r <repo> <filename>\n")
|
|
359
|
+
print("To set a default repository:")
|
|
360
|
+
print(" codefetch --set-default <owner>/<repo>\n")
|
|
361
|
+
print("Run 'codefetch --help' for more options.")
|
|
362
|
+
return
|
|
363
|
+
|
|
343
364
|
clean_filename = filename.strip("/\\")
|
|
344
365
|
|
|
345
366
|
def download_url(url):
|
|
@@ -373,11 +394,11 @@ def fetch_file(filename, owner=DEFAULT_OWNER, repo=DEFAULT_REPO, branch=DEFAULT_
|
|
|
373
394
|
if other_repo:
|
|
374
395
|
print(f"File not found: '{clean_filename}' in {owner}/{repo}.")
|
|
375
396
|
print(f"\n[Tip] Found '{other_match}' in repository '{other_repo}'!")
|
|
376
|
-
print(f"To fetch it, run:\n codefetch
|
|
397
|
+
print(f"To fetch it, run:\n codefetch {owner}/{other_repo} {other_match}")
|
|
377
398
|
return
|
|
378
399
|
else:
|
|
379
400
|
print(f"File not found: '{clean_filename}' in {owner}/{repo}.")
|
|
380
|
-
print(f"Run 'codefetch -
|
|
401
|
+
print(f"Run 'codefetch -l {owner}/{repo}' to see available files.")
|
|
381
402
|
return
|
|
382
403
|
except Exception:
|
|
383
404
|
print(f"File not found: '{clean_filename}' in {owner}/{repo}.")
|
|
@@ -427,17 +448,17 @@ def build_parser():
|
|
|
427
448
|
parser.add_argument(
|
|
428
449
|
"args",
|
|
429
450
|
nargs="*",
|
|
430
|
-
help="Target specification:
|
|
451
|
+
help="Target specification: <owner>/<repo> <filename> or <filename>",
|
|
431
452
|
)
|
|
432
453
|
parser.add_argument(
|
|
433
454
|
"-r", "--repo",
|
|
434
455
|
default=None,
|
|
435
|
-
help="Repository name or URL (e.g.
|
|
456
|
+
help="Repository name or URL (e.g. repo or owner/repo)",
|
|
436
457
|
)
|
|
437
458
|
parser.add_argument(
|
|
438
459
|
"-u", "--user",
|
|
439
460
|
default=None,
|
|
440
|
-
help=
|
|
461
|
+
help="GitHub user/org name",
|
|
441
462
|
)
|
|
442
463
|
parser.add_argument(
|
|
443
464
|
"-b", "--branch",
|
|
@@ -452,7 +473,7 @@ def build_parser():
|
|
|
452
473
|
parser.add_argument(
|
|
453
474
|
"-R", "--repos",
|
|
454
475
|
action="store_true",
|
|
455
|
-
help="List all public repositories for
|
|
476
|
+
help="List all public repositories for a user",
|
|
456
477
|
)
|
|
457
478
|
parser.add_argument(
|
|
458
479
|
"-s", "--show",
|
|
@@ -487,13 +508,13 @@ def build_parser():
|
|
|
487
508
|
parser.add_argument(
|
|
488
509
|
"-v", "--version",
|
|
489
510
|
action="version",
|
|
490
|
-
version="codefetch 1.2.
|
|
511
|
+
version="codefetch 1.2.2",
|
|
491
512
|
)
|
|
492
513
|
return parser
|
|
493
514
|
|
|
494
515
|
|
|
495
516
|
def resolve_invocation(positional_args, repo_flag, user_flag, branch_flag,
|
|
496
|
-
default_owner, default_repo, default_branch
|
|
517
|
+
default_owner, default_repo, default_branch):
|
|
497
518
|
"""
|
|
498
519
|
Resolve arguments into (owner, repo, branch, filename).
|
|
499
520
|
"""
|
|
@@ -530,7 +551,7 @@ def resolve_invocation(positional_args, repo_flag, user_flag, branch_flag,
|
|
|
530
551
|
if m:
|
|
531
552
|
return m.group(1), m.group(2), m.group(3), m.group(4)
|
|
532
553
|
|
|
533
|
-
# 3. Colon syntax: user/repo:filename
|
|
554
|
+
# 3. Colon syntax: user/repo:filename
|
|
534
555
|
if ":" in target:
|
|
535
556
|
repo_part, file_part = target.split(":", 1)
|
|
536
557
|
p_owner, p_repo = parse_repo_identifier(repo_part, default_owner=owner)
|
|
@@ -542,9 +563,12 @@ def resolve_invocation(positional_args, repo_flag, user_flag, branch_flag,
|
|
|
542
563
|
return parts[0], parts[1], branch, "/".join(parts[2:])
|
|
543
564
|
|
|
544
565
|
if len(parts) == 2:
|
|
545
|
-
|
|
566
|
+
if owner:
|
|
567
|
+
return owner, parts[0], branch, parts[1]
|
|
568
|
+
else:
|
|
569
|
+
return parts[0], parts[1], branch, None
|
|
546
570
|
|
|
547
|
-
# Single filename, e.g.
|
|
571
|
+
# Single filename, e.g. main.py (requires default_owner and default_repo)
|
|
548
572
|
return owner, repo, branch, target
|
|
549
573
|
|
|
550
574
|
|
|
@@ -565,7 +589,7 @@ def main():
|
|
|
565
589
|
except Exception as e:
|
|
566
590
|
print(f"Error removing config file: {e}")
|
|
567
591
|
return
|
|
568
|
-
print(
|
|
592
|
+
print("Configuration reset to defaults (no default repository or user).")
|
|
569
593
|
return
|
|
570
594
|
|
|
571
595
|
# Handle --set-default-user
|
|
@@ -577,9 +601,10 @@ def main():
|
|
|
577
601
|
|
|
578
602
|
# Handle --set-default
|
|
579
603
|
if args.set_default:
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
604
|
+
owner_part, repo_part = parse_repo_identifier(args.set_default, default_owner=args.user)
|
|
605
|
+
owner_to_save = owner_part or (args.user if args.user else None)
|
|
606
|
+
save_config(owner=owner_to_save, repo=repo_part)
|
|
607
|
+
print(f"Default repository updated to: '{repo_part}'")
|
|
583
608
|
if owner_to_save:
|
|
584
609
|
print(f"Default user updated to: '{owner_to_save}'")
|
|
585
610
|
print(f"Saved to: {CONFIG_FILE}")
|
|
@@ -588,8 +613,8 @@ def main():
|
|
|
588
613
|
# Handle --config
|
|
589
614
|
if args.config:
|
|
590
615
|
print("CodeFetch Configuration:")
|
|
591
|
-
print(f" Default User: {default_owner}")
|
|
592
|
-
print(f" Default Repository: {default_repo}")
|
|
616
|
+
print(f" Default User: {default_owner or 'None (not set)'}")
|
|
617
|
+
print(f" Default Repository: {default_repo or 'None (not set)'}")
|
|
593
618
|
print(f" Default Branch: {default_branch}")
|
|
594
619
|
print(f" Config File: {CONFIG_FILE}")
|
|
595
620
|
return
|
|
@@ -602,6 +627,12 @@ def main():
|
|
|
602
627
|
target_owner = owner
|
|
603
628
|
if args.args:
|
|
604
629
|
target_owner = args.args[0]
|
|
630
|
+
if not target_owner:
|
|
631
|
+
print("Error: No GitHub user specified.\n")
|
|
632
|
+
print("Usage:")
|
|
633
|
+
print(" codefetch --repos <username>")
|
|
634
|
+
print(" codefetch -R -u <username>")
|
|
635
|
+
return
|
|
605
636
|
list_repos(owner=target_owner, default_repo=default_repo)
|
|
606
637
|
return
|
|
607
638
|
|
|
@@ -613,6 +644,12 @@ def main():
|
|
|
613
644
|
target_owner, target_repo = parse_repo_identifier(args.repo, default_owner=owner)
|
|
614
645
|
elif args.args:
|
|
615
646
|
target_owner, target_repo = parse_repo_identifier(args.args[0], default_owner=owner)
|
|
647
|
+
if not target_owner or not target_repo:
|
|
648
|
+
print("Error: No repository specified to list.\n")
|
|
649
|
+
print("Usage:")
|
|
650
|
+
print(" codefetch -l <owner>/<repo>")
|
|
651
|
+
print(" codefetch -u <owner> -r <repo> -l")
|
|
652
|
+
return
|
|
616
653
|
list_files(owner=target_owner, repo=target_repo, branch=branch)
|
|
617
654
|
return
|
|
618
655
|
|
|
@@ -621,8 +658,6 @@ def main():
|
|
|
621
658
|
parser.print_help()
|
|
622
659
|
return
|
|
623
660
|
|
|
624
|
-
known_repos = [default_repo, "DS", "MPL", "Discord-Chatbot", "Codefetch"]
|
|
625
|
-
|
|
626
661
|
resolved_owner, resolved_repo, resolved_branch, resolved_filename = resolve_invocation(
|
|
627
662
|
args.args,
|
|
628
663
|
args.repo,
|
|
@@ -631,14 +666,12 @@ def main():
|
|
|
631
666
|
default_owner,
|
|
632
667
|
default_repo,
|
|
633
668
|
default_branch,
|
|
634
|
-
known_repos=known_repos,
|
|
635
669
|
)
|
|
636
670
|
|
|
637
671
|
if not resolved_filename:
|
|
638
672
|
print("Error: No filename specified.\n")
|
|
639
673
|
print("Usage:")
|
|
640
|
-
print(" codefetch <filename>
|
|
641
|
-
print(" codefetch <repo> <filename> Download from a repository")
|
|
674
|
+
print(" codefetch <owner>/<repo> <filename>")
|
|
642
675
|
print(" codefetch --help View full guide and examples")
|
|
643
676
|
return
|
|
644
677
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codefetch-cli
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: Quickly fetch code files from GitHub repositories with simple commands
|
|
5
5
|
Home-page: https://github.com/InzamamulQureshi/Codefetch
|
|
6
6
|
Author: Inzamamul Qureshi
|
|
@@ -30,13 +30,13 @@ CodeFetch is a lightweight command-line utility designed to quickly inspect, pre
|
|
|
30
30
|
|
|
31
31
|
## Features
|
|
32
32
|
|
|
33
|
-
- **Any User & Repository**: Fetch files from any public GitHub repository using intuitive syntax (`codefetch <
|
|
33
|
+
- **Any User & Repository**: Fetch files from any public GitHub repository using intuitive syntax (`codefetch <owner>/<repo> <filename>`).
|
|
34
34
|
- **Terminal Preview**: Inspect code directly in your console with `--show` without saving it to disk.
|
|
35
|
-
- **Automatic Path & Case Resolution**: Automatically resolves case mismatches
|
|
35
|
+
- **Automatic Path & Case Resolution**: Automatically resolves case mismatches and finds files nested inside subdirectories.
|
|
36
36
|
- **Repository Discovery**: List all public repositories for any GitHub user with `--repos`.
|
|
37
37
|
- **Tree Exploration**: List all supported code files within a repository with `--list`.
|
|
38
|
-
- **Persistent Defaults**:
|
|
39
|
-
- **
|
|
38
|
+
- **Optional Persistent Defaults**: Save a default repository or user with `--set-default` if you frequently work with the same repository.
|
|
39
|
+
- **Zero Runtime Dependencies**: Built using only the Python standard library with zero third-party dependencies.
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
@@ -70,80 +70,61 @@ pip install .
|
|
|
70
70
|
|
|
71
71
|
### 1. Download Files
|
|
72
72
|
|
|
73
|
-
Fetch a file from any GitHub repository:
|
|
73
|
+
Fetch a single file from any GitHub repository:
|
|
74
74
|
|
|
75
75
|
```bash
|
|
76
|
-
# Fetch from
|
|
77
|
-
codefetch
|
|
76
|
+
# Fetch a file from any user and repository
|
|
77
|
+
codefetch owner/repo main.py
|
|
78
78
|
|
|
79
|
-
#
|
|
80
|
-
codefetch
|
|
79
|
+
# Download a configuration or dataset
|
|
80
|
+
codefetch owner/repo data.csv
|
|
81
|
+
codefetch owner/repo config.yaml
|
|
81
82
|
|
|
82
|
-
#
|
|
83
|
-
codefetch
|
|
84
|
-
codefetch -r DS EXP1.c
|
|
83
|
+
# Download using explicit flags
|
|
84
|
+
codefetch -u owner -r repo main.py
|
|
85
85
|
|
|
86
|
-
#
|
|
87
|
-
codefetch
|
|
88
|
-
|
|
89
|
-
# Fetch from the default repository
|
|
90
|
-
codefetch 8.1.py
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Save to a custom filename or directory using `-o` / `--output`:
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
codefetch -r DS EXP1.c -o my_experiment.c
|
|
86
|
+
# Save with a custom filename or destination path
|
|
87
|
+
codefetch owner/repo main.py -o custom_name.py
|
|
97
88
|
```
|
|
98
89
|
|
|
99
90
|
### 2. Preview in Terminal (Without Downloading)
|
|
100
91
|
|
|
101
|
-
Display the contents of a file directly in stdout
|
|
92
|
+
Display the contents of a file directly in stdout with `-s` / `--show`:
|
|
102
93
|
|
|
103
94
|
```bash
|
|
104
|
-
# Preview file
|
|
105
|
-
codefetch
|
|
106
|
-
|
|
107
|
-
# Preview file from another repository
|
|
108
|
-
codefetch --show DS/EXP1.c
|
|
109
|
-
|
|
110
|
-
# Preview file from any user repository
|
|
111
|
-
codefetch --show InzamamulQureshi/Codefetch setup.py
|
|
95
|
+
# Preview file content in terminal
|
|
96
|
+
codefetch -s owner/repo main.py
|
|
97
|
+
codefetch -s torvalds/linux Makefile
|
|
112
98
|
```
|
|
113
99
|
|
|
114
100
|
### 3. Explore Repositories and Files
|
|
115
101
|
|
|
116
102
|
```bash
|
|
117
|
-
# List all
|
|
118
|
-
codefetch
|
|
119
|
-
|
|
120
|
-
# List all public repositories for a specific user
|
|
121
|
-
codefetch --repos -u InzamamulQureshi
|
|
122
|
-
codefetch --repos torvalds
|
|
103
|
+
# List all code files in a repository
|
|
104
|
+
codefetch -l owner/repo
|
|
105
|
+
codefetch --list owner/repo
|
|
123
106
|
|
|
124
|
-
# List
|
|
125
|
-
codefetch
|
|
126
|
-
|
|
127
|
-
# List code files in another repository
|
|
128
|
-
codefetch -r DS --list
|
|
129
|
-
codefetch --list InzamamulQureshi/Codefetch
|
|
107
|
+
# List all public repositories for any GitHub user
|
|
108
|
+
codefetch -R -u username
|
|
109
|
+
codefetch --repos username
|
|
130
110
|
```
|
|
131
111
|
|
|
132
|
-
### 4. Configuration and Defaults
|
|
112
|
+
### 4. Configuration and Defaults (Optional)
|
|
133
113
|
|
|
134
|
-
|
|
114
|
+
By default, CodeFetch has no preset repository or user. If you frequently fetch files from the same repository, you can optionally configure defaults:
|
|
135
115
|
|
|
136
116
|
```bash
|
|
137
|
-
# Set default repository
|
|
138
|
-
codefetch --set-default
|
|
117
|
+
# Set a default repository (saves both user and repo)
|
|
118
|
+
codefetch --set-default owner/repo
|
|
139
119
|
|
|
140
|
-
#
|
|
141
|
-
codefetch
|
|
120
|
+
# Now you can fetch files directly without typing the repo name!
|
|
121
|
+
codefetch main.py
|
|
122
|
+
codefetch -l
|
|
142
123
|
|
|
143
|
-
# View current configuration
|
|
124
|
+
# View current saved configuration
|
|
144
125
|
codefetch --config
|
|
145
126
|
|
|
146
|
-
# Reset configuration back to
|
|
127
|
+
# Reset all configuration back to defaults (no default repository)
|
|
147
128
|
codefetch --reset-config
|
|
148
129
|
```
|
|
149
130
|
|
|
@@ -153,17 +134,17 @@ codefetch --reset-config
|
|
|
153
134
|
|
|
154
135
|
| Flag | Description | Example |
|
|
155
136
|
|---|---|---|
|
|
156
|
-
| `-
|
|
157
|
-
| `-
|
|
158
|
-
| `-
|
|
159
|
-
| `-
|
|
160
|
-
| `-
|
|
161
|
-
| `-
|
|
162
|
-
| `-
|
|
163
|
-
| `--set-default` | Set persistent default repository | `codefetch --set-default
|
|
164
|
-
| `--set-default-user` | Set persistent default user | `codefetch --set-default-user
|
|
137
|
+
| `-s`, `--show` | Print file contents to terminal | `codefetch -s owner/repo main.py` |
|
|
138
|
+
| `-o`, `--output` | Specify destination output filename | `codefetch owner/repo main.py -o script.py` |
|
|
139
|
+
| `-l`, `--list` | List available code files in a repository | `codefetch -l owner/repo` |
|
|
140
|
+
| `-R`, `--repos` | List public repositories for a user | `codefetch -R -u username` |
|
|
141
|
+
| `-r`, `--repo` | Specify repository name or URL | `codefetch -r repo main.py` |
|
|
142
|
+
| `-u`, `--user` | Specify GitHub username or organization | `codefetch -u username -r repo main.py` |
|
|
143
|
+
| `-b`, `--branch` | Branch name (default: `main`) | `codefetch -b master owner/repo Makefile` |
|
|
144
|
+
| `--set-default` | Set persistent default repository | `codefetch --set-default owner/repo` |
|
|
145
|
+
| `--set-default-user` | Set persistent default user | `codefetch --set-default-user username` |
|
|
165
146
|
| `--config` | Display active configuration | `codefetch --config` |
|
|
166
|
-
| `--reset-config` | Reset configuration to defaults | `codefetch --reset-config` |
|
|
147
|
+
| `--reset-config` | Reset configuration back to defaults | `codefetch --reset-config` |
|
|
167
148
|
| `-v`, `--version` | Display version information | `codefetch --version` |
|
|
168
149
|
| `-h`, `--help` | Display help and usage message | `codefetch --help` |
|
|
169
150
|
|
|
@@ -171,6 +152,8 @@ codefetch --reset-config
|
|
|
171
152
|
|
|
172
153
|
## Supported File Extensions
|
|
173
154
|
|
|
155
|
+
CodeFetch recognizes and lists common source and document files:
|
|
156
|
+
|
|
174
157
|
- **Data & Tables**: `.csv`, `.tsv`, `.json`, `.jsonl`, `.yaml`, `.yml`, `.toml`, `.xml`, `.ini`, `.cfg`, `.conf`, `.env`
|
|
175
158
|
- **Data Science**: `.ipynb`, `.py`, `.r`, `.rmd`, `.m`
|
|
176
159
|
- **Languages**: `.c`, `.cpp`, `.h`, `.hpp`, `.rs`, `.go`, `.java`, `.kt`, `.cs`, `.swift`, `.dart`, `.php`
|
|
@@ -7,7 +7,7 @@ long_description = readme_path.read_text(encoding="utf-8") if readme_path.exists
|
|
|
7
7
|
|
|
8
8
|
setup(
|
|
9
9
|
name="codefetch-cli",
|
|
10
|
-
version="1.2.
|
|
10
|
+
version="1.2.2",
|
|
11
11
|
description="Quickly fetch code files from GitHub repositories with simple commands",
|
|
12
12
|
long_description=long_description,
|
|
13
13
|
long_description_content_type="text/markdown",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|