refactor: modularize CLI architecture and add hooks support #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactor: Modularize CLI Architecture and Add Hooks Support
Overview
This PR represents a major architectural refactoring of uvtask, transforming the monolithic CLI implementation into a modular, testable architecture while adding new features and infrastructure improvements.
🏗️ Architecture Refactoring
Modular Design
The monolithic
cli.pyfile (847 lines) has been split into focused, single-responsibility modules:colors.py: Color management and terminal output formatting--colorflag (auto/always/never)commands.py: Command execution and script loadingpyproject.tomlconfig.py: Configuration parsing and pyproject.toml handlingexecutor.py: Command execution with quiet/verbose supportformatters.py: Custom argparse formatters and help text processinguvCLI stylehooks.py: Pre/post hook discovery and validationparser.py: Argument parsing and CLI builderBenefits
✨ New Features
Pre/Post Hooks Support
Added comprehensive hook functionality supporting both naming conventions:
Composer-style hooks:
NPM-style hooks:
Features:
--no-hooksand--ignore-scriptsflags to skip hooks🚀 Infrastructure
CI/CD Pipelines
Added GitHub Actions workflows for automated testing and deployment:
CI Pipeline (
ci.yml):CD Pipeline (
cd.yml):🧪 Testing
Comprehensive Test Coverage
Added unit tests for all new modules:
test_cli.py: CLI integration and end-to-end teststest_commands.py: Command execution and script loading teststest_config.py: Configuration parsing and TOML handling teststest_executor.py: Command executor with quiet/verbose mode teststest_formatters.py: Help formatter and argument parsing teststest_hooks.py: Hook discovery, validation, and execution teststest_parser.py: Argument parser and CLI builder tests📚 Documentation
🔄 Backward Compatibility
All changes maintain backward compatibility:
📦 Dependencies
typackage from 0.0.6 to 0.0.7🎯 Impact
Testing
Checklist