Skip to content

Refactor CLI structure and enhance command registration#1

Closed
mgwilt wants to merge 2 commits into
mainfrom
cli-organization
Closed

Refactor CLI structure and enhance command registration#1
mgwilt wants to merge 2 commits into
mainfrom
cli-organization

Conversation

@mgwilt
Copy link
Copy Markdown

@mgwilt mgwilt commented Sep 30, 2025

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.

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.
@mgwilt mgwilt requested review from Copilot and sbaker and removed request for Copilot and sbaker September 30, 2025 16:22
@mgwilt mgwilt self-assigned this Sep 30, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread cli/python/prompd/commands/version_cmds.py
if line.strip():
parts = line.split("|", 3)
if len(parts) == 4 and "tag:" in parts[0]:
import re
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
):
"""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]
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread cli/python/prompd/commands/common.py Outdated
if not package:
config_file = Path.cwd() / ".prompd" / "config.yaml"
if config_file.exists():
import yaml
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@mgwilt mgwilt requested a review from sbaker September 30, 2025 16:25
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@mgwilt mgwilt closed this Sep 30, 2025
@mgwilt mgwilt deleted the cli-organization branch September 30, 2025 23:07
@mgwilt mgwilt restored the cli-organization branch September 30, 2025 23:13
@mgwilt mgwilt reopened this Sep 30, 2025
@mgwilt mgwilt closed this Dec 30, 2025
@mgwilt mgwilt deleted the cli-organization branch December 30, 2025 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants