Skip to main content

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, clone the repository and install the dependencies:

git clone https://github.com/hissain/ghcs.git
cd ghcs
pip install -r requirements.txt

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

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

ghcs-0.0.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ghcs-0.0.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file ghcs-0.0.1.tar.gz.

File metadata

  • Download URL: ghcs-0.0.1.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

Hashes for ghcs-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3c3ed0a9eefeb978840e7ac50a07f0245fca7fafd50d9760cbe2676703e58aa3
MD5 cf799f3fc5a0d6d19e4778edb1e255c5
BLAKE2b-256 0eedaacc8e79d54307f67baf023d4b2269217fc4b60f2eb36bd795de0f82c24c

See more details on using hashes here.

File details

Details for the file ghcs-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: ghcs-0.0.1-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

Hashes for ghcs-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3450b04ebc20e795f051e3af3220f7f3660f367a50d66003edec968a9ecd23aa
MD5 32bc5a4b2ebdddc9a0d72288f406c932
BLAKE2b-256 232f316caa48eedb76edcb0727f6cc7ab9bb06bc8226d02d02910353fd463d08

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page