Refactor CLI structure and enhance command registration#1
Conversation
Updated the CLI implementation by consolidating command registrations for improved organization and maintainability. Introduced new command definitions for creating and validating packages, along with enhancements to the create command for .prmd files. Streamlined imports for faster startup and improved error handling across commands. This refactor aims to enhance user experience and command accessibility within the Prompd CLI.
There was a problem hiding this comment.
Pull Request Overview
This PR consolidates CLI command registrations by extracting command implementations into individual modules under prompd/commands/. The refactor organizes 25+ CLI commands across specialized modules (create, run, validate, package management, git operations, etc.) while introducing a shared console configuration and common utilities to enhance maintainability and startup performance.
- Modular command organization with dedicated files for each command group
- Shared console configuration and utilities for consistent CLI behavior
- Enhanced command definitions including new package and namespace management features
Reviewed Changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| cli/python/prompd/console.py | Centralized Rich console configuration with cross-platform support |
| cli/python/prompd/commands/common.py | Shared utilities and console import for command modules |
| cli/python/prompd/commands/*.py | Individual command implementations (25 files) extracted from main CLI |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| def _update_version_in_file(file_path: Path, new_version: str): | ||
| content = file_path.read_text(encoding="utf-8") | ||
|
|
||
| import re |
There was a problem hiding this comment.
Move the import re statement to the top of the file with other imports rather than importing it locally within the function for better code organization and performance.
| if line.strip(): | ||
| parts = line.split("|", 3) | ||
| if len(parts) == 4 and "tag:" in parts[0]: | ||
| import re |
There was a problem hiding this comment.
Move the import re statement to the top of the file with other imports rather than importing it locally within the function for better code organization and performance. This is a duplicate import that should be consolidated with the one at the top level.
| ): | ||
| """Create a .pdpkg package from a directory (alias for `package create`).""" | ||
| try: | ||
| package_create.callback(source, output_path, name, version, description, author) # type: ignore[attr-defined] |
There was a problem hiding this comment.
Using .callback on a Click command function is an implementation detail that could break with Click version changes. Consider importing and calling the function directly or restructuring the code to avoid this internal API usage.
| if not package: | ||
| config_file = Path.cwd() / ".prompd" / "config.yaml" | ||
| if config_file.exists(): | ||
| import yaml |
There was a problem hiding this comment.
Move the import yaml statement to the top of the file with other imports rather than importing it locally within the conditional block for better code organization.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Updated the CLI implementation by consolidating command registrations for improved organization and maintainability. Introduced new command definitions for creating and validating packages, along with enhancements to the create command for .prmd files. Streamlined imports for faster startup and improved error handling across commands. This refactor aims to enhance user experience and command accessibility within the Prompd CLI.