feat: add --version flag to CLI#39
Merged
LittleCoinCoin merged 4 commits intoCrackingShells:devfrom Oct 2, 2025
Merged
Conversation
added 4 commits
October 2, 2025 19:18
Add comprehensive test suite for hatch --version command implementation: - test_get_hatch_version_retrieves_from_metadata: Unit test for version retrieval - test_get_hatch_version_handles_package_not_found: Unit test for error handling - test_version_command_displays_correct_format: Integration test for CLI flow - test_import_hatch_without_version_attribute: Integration test for import safety - test_no_conflict_with_package_version_flag: Regression test for flag conflicts Tests follow CrackingShells testing standards using wobble framework. All 5 tests pass with 100% pass rate. Related to: Phase 2 test definition (test_definition_v1.md)
Remove hardcoded version string (__version__ = '0.4.0') from hatch/__init__.py.
This eliminates version duplication and establishes pyproject.toml as the single
source of truth for version information. Version will now be retrieved dynamically
via importlib.metadata.version('hatch').
Breaking change: Code that relied on hatch.__version__ will need to use
importlib.metadata.version('hatch') instead.
Related to: Phase 1 analysis (version_command_analysis_v1.md)
Implement hatch --version command to display application version:
- Add importlib.metadata imports (version, PackageNotFoundError)
- Add get_hatch_version() helper function with error handling
- Add --version argument to main parser using argparse action='version'
The version is retrieved dynamically from package metadata via
importlib.metadata.version('hatch'). Falls back to 'unknown (development mode)'
if package is not installed.
Output format: 'hatch <version>' (e.g., 'hatch 0.6.1')
No short form (-v) to avoid conflict with existing package version flag
in subcommands.
Related to: Phase 1 analysis (version_command_analysis_v1.md)
Update documentation to include the new --version flag: - CLI Reference: Add --version to global options table with usage example - Getting Started: Update Step 3 verification to use 'hatch --version' first - Installation Tutorial: Add version check to installation verification steps - README: Add version check after installation instructions The --version flag provides a quick way to verify successful installation and check the installed Hatch version. Related to: feature/hatch-version-command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implements
hatch --versioncommand to display the Hatch application version following modern Python best practices.Changes
This PR includes 4 focused commits:
__version__fromhatch/__init__.py--versionflag to CLI argument parserImplementation Details
importlib.metadata.version('hatch')for dynamic version retrieval frompyproject.tomlhatch <version>(e.g.,hatch 0.6.1)-vshort form to avoid conflict with existing package version flagTest Results
✅ 5/5 tests passing (100% pass rate)
test_get_hatch_version_retrieves_from_metadata- Unit test for version retrievaltest_get_hatch_version_handles_package_not_found- Unit test for error handlingtest_version_command_displays_correct_format- Integration test for CLI flowtest_import_hatch_without_version_attribute- Integration test for import safetytest_no_conflict_with_package_version_flag- Regression test for flag conflictsDocumentation Updates
--versionto global options tablehatch --versionBreaking Changes
__version__attribute: Code that relied onhatch.__version__will need to useimportlib.metadata.version('hatch')instead.This establishes
pyproject.tomlas the single source of truth for version information.Implementation Reports
Detailed implementation documentation available in
Laghari/Augment/Cracking_Shells/Hatch/version_command/:Verification
Related Issues
N/A - New feature implementation
Ready for review - All phases complete (Analysis, Test Definition, Implementation, Debugging, Git Commits, Documentation, Knowledge Transfer)
Pull Request opened by Augment Code with guidance from the PR author