| Crates.io | github-code-searching |
| lib.rs | github-code-searching |
| version | 0.3.1 |
| created_at | 2025-04-10 11:09:33.17389+00 |
| updated_at | 2025-04-10 13:13:43.985959+00 |
| description | Search and save code for keywords from GitHub |
| homepage | |
| repository | https://github.com/manorajesh/github-code-searching |
| max_upload_size | |
| id | 1628065 |
| size | 94,333 |
A powerful, concurrent CLI tool for searching code across GitHub repositories with advanced rate-limit handling and progress visualization.
# Clone the repository
git clone https://github.com/manorajesh/github-code-searching.git
cd github-code-searching
# Build the project
cargo build --release
# The binary will be available at
# ./target/release/github-code-searching
# Basic usage
github-code-searching --words "rust concurrency" "tokio async" --token YOUR_GITHUB_TOKEN
# Search with environment variable for token
export GITHUB_TOKEN=your_github_token
github-code-searching -w "axum router" "rocket framework"
# Control concurrency and output location
github-code-searching -w "security vulnerability" "authentication bypass" -c 3 -o security_findings.json
# Limit pages per search term
github-code-searching -w "kubernetes operator" -p 5
| Argument | Short | Long | Description | Default |
|---|---|---|---|---|
| Search terms | -w |
--words |
Words to search for (required, multiple allowed) | - |
| Output file | -o |
--output |
Path for JSON results | search_results.json |
| Max pages | -p |
--max-pages |
Maximum pages per search term | No limit |
| GitHub token | -t |
--token |
GitHub API token | Uses GITHUB_TOKEN env var |
| Concurrency | -c |
--concurrency |
Number of concurrent searches | 2 |
The tool requires a GitHub token with appropriate permissions:
--token argument to provide your token directlyGITHUB_TOKEN environment variable.env file in the project directory with GITHUB_TOKEN=your_tokenResults are saved in JSON format with the following structure for each match:
{
"name": "filename.ext",
"html_url": "https://github.com/owner/repo/blob/...",
"sha": "commit-hash",
"search_term": "search-word",
"repository_owner": {
"login": "owner-name",
"avatar_url": "https://avatars.githubusercontent.com/...",
"html_url": "https://github.com/owner"
},
"text_matches": [
{
"object_url": "https://api.github.com/...",
"object_type": "FileContent",
"property": "content",
"fragment": "code fragment containing match",
"matches": [
{
"text": "matched text",
"indices": [start, end]
}
]
}
]
}
GitHub Code Searcher performs the following operations:
The tool includes sophisticated rate-limit management:
src/main.rs: Entry point and CLI argument parsingsrc/github_searcher.rs: Core search functionality and API interaction# Run with debug output
RUST_LOG=debug cargo run -- -w "example search term"
# Run tests
cargo test
Contributions are welcome! Please feel free to submit a Pull Request.