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 and so on).
  • 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 'search_term' --token YOUR_GITHUB_TOKEN

Search with Filters

ghcs 'search_term' --user 'username' --repo 'username/repo' --language 'python' --path '*.py' --token YOUR_GITHUB_TOKEN --max-results MAX_RESULT_COUNT

Download Matched Files

ghcs 'search_term' --download --token YOUR_GITHUB_TOKEN

Arguments

  • -h, --help: Show the help menu and exit.

Positional:

  • --query: Search term (required).

Optional:

  • -l, --language: Programming language filter.
  • -u, --user: Search in all repositories of a specific user.
  • -r, --repo: Search in a specific repository (e.g., username/repo).
  • -p, --path: Specify path specifier for filtering.
  • -t, --token: GitHub Personal Access Token (or set GITHUB_TOKEN environment variable).
  • -m, --max-result: Limit the search results to show or download.
  • -d, --download: Download matched files.
  • -dd, --download-dir: Download directory for downloading the matched files.
  • -v, --verbose: Verbose logging for matched files.

GITHUB_TOKEN can be generated from https://github.com/settings/tokens

Example

ghcs 'def main' --language 'python' --user 'hissain' --path '*.py' --download --token YOUR_GITHUB_TOKEN --max-results 5
ghcs "def train()" path llm --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.1.0.tar.gz (4.6 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.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ghcs-0.1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for ghcs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 261921b40c494753e6e741f6a979fb79861e6aa21c3f285e67f3de2f1caacaf9
MD5 aa2e5a082ae190b980121ae2a2c2c36e
BLAKE2b-256 2e0da95389a6dd3f2a32bc782689eab65d8b882d4b9ea9dfba0ef29dc2a302b9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ghcs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b751a46a60b022a8f0d6506d9c055ad97ed41d2b0e368aafc859805af78e8936
MD5 8935fd13d3f35cf980986efe02570b34
BLAKE2b-256 d4ba944c78937eff5f81e9e21d055fd00dbaf19c16bdd0cb72da40967e9b7595

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