Skip to main content

A CLI tool for managing GitHub PR code reviews efficiently

Project description

Toady CLI ๐Ÿธ

CI codecov PyPI version Python versions License: MIT Code style: black Ruff

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

๐Ÿš€ 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 dependencies
  • integration: Tests requiring GitHub CLI or external services
  • slow: Performance tests and benchmarks
  • cli: Command-line interface integration tests
  • service: 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:

  1. Environment Validation: Verify all tools are available
  2. Code Formatting: Check Black formatting compliance
  3. Linting: Run Ruff analysis for code quality
  4. Type Checking: Validate type hints with MyPy
  5. 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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Run tests and checks (make check)
  4. Commit your changes (git commit -m 'Add amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. 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 --debug flag for detailed error info
  • Use --format pretty for human-readable output during testing

ID Issues

  • Always use thread IDs from toady fetch output
  • Use toady reply --help-ids for complete ID documentation
  • Thread IDs (PRRT_, PRT_, RT_) are more reliable than comment IDs

Rate Limiting

  • Use --limit option 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toady_cli-0.1.0.tar.gz (95.2 kB view details)

Uploaded Source

Built Distribution

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

toady_cli-0.1.0-py3-none-any.whl (105.8 kB view details)

Uploaded Python 3

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

Hashes for toady_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5d08b455ddcf26a34f4ebc688572130904c8a6330ab43a6e499b2e725880dc3e
MD5 29abf9682d77ad4f7d9bc39e107f10d2
BLAKE2b-256 dd5e31b2cd328a13874b542642757d5106eb9d17323edc0adf62b37221cc5cc3

See more details on using hashes here.

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

Hashes for toady_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 191b562d349c633af44020b54ad2a9044ab8d5a3db2b7b4973287bd3a083a432
MD5 77297a7723ae3853a209397eb80ae3ae
BLAKE2b-256 d68e987a4b99884c9de0089653479fafe6baf69ed75ffdcad1e6b6beebb27e8d

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