A CLI tool for managing GitHub PR code reviews efficiently
Project description
Toady CLI ๐ธ
A modern CLI tool for efficiently managing GitHub pull request code reviews. Toady helps you fetch unresolved review comments, post replies, and manage review thread resolutionโall from your command line.
โจ Features
- ๐ Fetch unresolved review threads from any GitHub pull request
- ๐ฌ Reply to review comments directly from your terminal
- โ Resolve/unresolve review threads with simple commands
- ๐จ Pretty output formatting for human readability
- ๐ค JSON output for automation and scripting
- ๐ Secure authentication via GitHub CLI (
gh) - ๐๏ธ Modular architecture with clean separation of concerns
- ๐งช Comprehensive testing with 80% coverage requirement
- โก Fast CI/CD pipeline with elegant reporting
- ๐ก๏ธ GraphQL schema validation for API compatibility
๐ Prerequisites
- Python 3.8 or higher
- GitHub CLI (
gh) installed and authenticated
๐ Installation
From PyPI (Recommended)
pip install toady-cli
From Source
git clone https://github.com/tonyblank/toady-cli.git
cd toady-cli
pip install -e .
Development Installation
git clone https://github.com/tonyblank/toady-cli.git
cd toady-cli
make install-dev
๐ฏ Quick Start
Fetch Unresolved Review Threads
# Auto-detect PR (recommended)
toady fetch
# Get unresolved threads from specific PR
toady fetch --pr 123
# Get human-readable output
toady fetch --format pretty
# Include resolved threads
toady fetch --resolved
Reply to a Review Comment
# Reply to a review thread (recommended)
toady reply --id PRRT_kwDOO3WQIc5Rv3_r --body "Thanks for the feedback! Fixed in latest commit."
# Reply using numeric ID (legacy)
toady reply --id 12345678 --body "Fixed!"
# Get help with ID types
toady reply --help-ids
Resolve/Unresolve Review Threads
# Resolve a thread
toady resolve --thread-id abc123def
# Unresolve a thread
toady resolve --thread-id abc123def --undo
# Resolve all unresolved threads at once
toady resolve --all --pr 123
Smart PR Detection
# Toady automatically detects your PR context:
# - Single PR: fetches automatically
# - Multiple PRs: shows interactive selection
# - No PRs: displays helpful message
toady fetch
# Override auto-detection for specific PR
toady fetch --pr 123
Schema Validation
# Validate all GraphQL queries against GitHub's schema
toady schema validate
# Validate a specific GraphQL query
toady schema check "query { ... }"
# Fetch and cache GitHub's GraphQL schema
toady schema fetch
๐ ๏ธ Development
Setup Development Environment
# Clone the repository
git clone https://github.com/tonyblank/toady-cli.git
cd toady-cli
# Install in development mode with all dependencies
make install-dev
๐๏ธ Architecture
Toady CLI follows a modular architecture with clear separation of concerns:
src/toady/
โโโ cli.py # Main CLI entry point and command registration
โโโ command_utils.py # CLI command utilities and helpers
โโโ error_handling.py # Error handling and exception management
โโโ exceptions.py # Custom exception hierarchy
โโโ utils.py # General utilities
โโโ commands/ # Modular command implementations
โ โโโ fetch.py # Fetch command logic
โ โโโ reply.py # Reply command logic
โ โโโ resolve.py # Resolve command logic
โ โโโ schema.py # Schema validation commands
โโโ services/ # Business logic services
โ โโโ github_service.py # Core GitHub API interactions
โ โโโ fetch_service.py # Fetch-specific business logic
โ โโโ reply_service.py # Reply-specific business logic
โ โโโ resolve_service.py # Resolution-specific business logic
โ โโโ pr_selection.py # PR selection logic
โ โโโ pr_selector.py # PR selector utilities
โโโ formatters/ # Output formatting modules
โ โโโ formatters.py # Main formatter logic
โ โโโ format_interfaces.py # Formatter interfaces and base classes
โ โโโ format_selection.py # Format selection utilities
โ โโโ json_formatter.py # JSON-specific formatting
โ โโโ pretty_formatter.py # Pretty output formatting
โโโ models/ # Data models
โ โโโ models.py # Data models for GitHub entities
โโโ parsers/ # Data parsing modules
โ โโโ graphql_parser.py # GraphQL query parsing
โ โโโ graphql_queries.py # GraphQL query definitions
โ โโโ parsers.py # Data parsing utilities
โโโ validators/ # Validation modules
โโโ node_id_validation.py # GitHub node ID validation
โโโ schema_validator.py # GraphQL schema validation
โโโ validation.py # General validation utilities
๐งช Testing
The project uses pytest with a comprehensive test suite organized by type:
# ๐ฏ Run comprehensive CI/CD pipeline (recommended)
make check
# ๐ Testing options:
make test # All tests with 80% coverage requirement
make test-fast # Fast unit tests only
make test-integration # Integration tests only
make test-performance # Performance benchmarks
make test-analysis # Generate detailed test suite analysis
# ๐ Code Quality:
make check-fast # Quick validation (no tests)
make lint # Run ruff linting
make format # Format with black
make type-check # Type check with mypy
make pre-commit # Run all pre-commit hooks
Test Organization
tests/
โโโ unit/ # Fast, isolated unit tests
โ โโโ services/ # Service layer tests
โ โโโ formatters/ # Output formatting tests
โ โโโ models/ # Data model tests
โ โโโ validators/ # Validation logic tests
โโโ integration/ # Integration tests
โ โโโ cli/ # CLI command tests using CliRunner
โ โโโ ... # GitHub API integration tests
โโโ conftest.py # Shared fixtures and test configuration
Test Categories
Tests are organized with pytest markers for targeted execution:
unit: Fast, isolated tests with no external dependenciesintegration: Tests requiring GitHub CLI or external servicesslow: Performance tests and benchmarkscli: Command-line interface integration testsservice: Service layer business logic tests
๐ฏ Quality Assurance
The project maintains high code quality through:
- Coverage Requirement: 80% test coverage minimum
- Code Formatting: Black for consistent code style
- Linting: Ruff for fast and comprehensive code analysis
- Type Checking: MyPy with strict configuration
- Pre-commit Hooks: Automatic code quality checks on every commit
- CI/CD Pipeline: Comprehensive checks with fail-fast behavior
CI/CD Pipeline
The make check command runs a comprehensive pipeline:
- Environment Validation: Verify all tools are available
- Code Formatting: Check Black formatting compliance
- Linting: Run Ruff analysis for code quality
- Type Checking: Validate type hints with MyPy
- Test Suite: Execute all 610+ tests with coverage tracking
The pipeline provides elegant, colorized output with detailed timing and failure reporting.
๐ฆ Building and Publishing
# Build distribution packages
make build
# Upload to PyPI (requires credentials)
twine upload dist/*
๐ค Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Run tests and checks (
make check) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Built with Click for elegant CLI interactions
- Styled with Rich for beautiful terminal output
- Integrates with GitHub CLI for secure API access
๐ Documentation
For more detailed documentation, visit our GitHub Wiki.
๐ ๏ธ Troubleshooting
Authentication Issues
- Run:
gh auth login - Verify:
gh auth status - Ensure repo scope:
gh auth login --scopes repo
Common Errors
- "authentication_required": GitHub CLI not logged in
- "pr_not_found": PR doesn't exist or no repository access
- "rate_limit_exceeded": Too many API calls, wait and retry
- "thread_not_found": Invalid thread ID or thread was deleted
Debug Mode
- Set TOADY_DEBUG=1 or use
--debugflag for detailed error info - Use
--format prettyfor human-readable output during testing
ID Issues
- Always use thread IDs from
toady fetchoutput - Use
toady reply --help-idsfor complete ID documentation - Thread IDs (PRRT_, PRT_, RT_) are more reliable than comment IDs
Rate Limiting
- Use
--limitoption to reduce API calls - Add delays between operations in scripts
- Check limits:
gh api rate_limit
๐ Bug Reports
Found a bug? Please open an issue with a clear description and steps to reproduce.
Project details
Release history Release notifications | RSS feed
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 toady_cli-0.1.0.tar.gz.
File metadata
- Download URL: toady_cli-0.1.0.tar.gz
- Upload date:
- Size: 95.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d08b455ddcf26a34f4ebc688572130904c8a6330ab43a6e499b2e725880dc3e
|
|
| MD5 |
29abf9682d77ad4f7d9bc39e107f10d2
|
|
| BLAKE2b-256 |
dd5e31b2cd328a13874b542642757d5106eb9d17323edc0adf62b37221cc5cc3
|
File details
Details for the file toady_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: toady_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 105.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
191b562d349c633af44020b54ad2a9044ab8d5a3db2b7b4973287bd3a083a432
|
|
| MD5 |
77297a7723ae3853a209397eb80ae3ae
|
|
| BLAKE2b-256 |
d68e987a4b99884c9de0089653479fafe6baf69ed75ffdcad1e6b6beebb27e8d
|