GitHub Code Search CLI with file downloading capability.
Project description
GitHub Code Search CLI (ghcs)
ghcs is a command-line interface (CLI) tool for searching code on GitHub and downloading matched files. It allows you to search for code snippets, filter by language, user, repository, and path, and optionally download the matched files. This is effective utility specially when developers are on CLI non ui environment (i.e. on remote desktop).
Features
- Search GitHub code with various filters (query, user, repository, language, path).
- Download matched files directly from GitHub.
- Easy to use CLI interface.
Installation
To install ghcs, simply use direct pip:
pip install ghcs
or for most updated, directly from Github, using
pip install git+https://github.com/hissain/ghcs.git
Usage
To use the ghcs CLI, you need a GitHub Personal Access Token. You can set it via the --token argument or the GITHUB_TOKEN environment variable.
Basic Search
ghcs --query 'search_term' --token YOUR_GITHUB_TOKEN
Search with Filters
ghcs --query 'search_term' --user 'username' --repo 'username/repo' --language 'python' --path '*.py' --token YOUR_GITHUB_TOKEN --max-results MAX_RESULT_COUNT
Download Matched Files
ghcs --query 'search_term' --download --token YOUR_GITHUB_TOKEN
Arguments
--query:Search term (required).--language:Programming language filter.--user:Search in all repositories of a specific user.--repo:Search in a specific repository (e.g., username/repo).--path:Specify path specifier for filtering.--token:GitHub Personal Access Token (or set GITHUB_TOKEN environment variable).--max-result:Limit the search results to show or download.--download:Download matched files.--download-dir:Download directory for downloading the matched files.
GITHUB_TOKEN can be generated from https://github.com/settings/tokens
Example
ghcs --query 'def main' --language 'python' --user 'hissain' --path '*.py' --download --token YOUR_GITHUB_TOKEN --max-results 5
ghcs --query "def main()" --user hissain --max-results 3 --download
License
This project is licensed under the MIT License. See the LICENSE file for details.
Author
Md. Sazzad Hissain Khan
- Email: hissain.khan@gmail.com
- GitHub: hissain
Feel free to modify the content as needed.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ghcs-0.0.2.tar.gz.
File metadata
- Download URL: ghcs-0.0.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a27dfc306e6663da1c509129436cac4fee93a26499f5b3c927b614613c4d37d2
|
|
| MD5 |
1c3c9ec2e2591c5d99ef3f8def897707
|
|
| BLAKE2b-256 |
ea6b906aaa50cecc436fdca726b341cf25b7f93690dc8d41ccc26021e4f3055a
|
File details
Details for the file ghcs-0.0.2-py3-none-any.whl.
File metadata
- Download URL: ghcs-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ec5ccf4652d9b9f1a0b181ca4d89057f6565573a2d5d3fe78c48f4cd3292271
|
|
| MD5 |
a801a862515a7cc5d8c96fcc531c135c
|
|
| BLAKE2b-256 |
af991a09feb3a7b610f54ffd5662da529d99e4eb1e327e16d5625cc23aa0f29d
|