Skip to content

refactor: split CLI command classes into separate files#15

Merged
rbcorrales merged 1 commit into
mainfrom
refactor/split-cli-command-classes
May 27, 2026
Merged

refactor: split CLI command classes into separate files#15
rbcorrales merged 1 commit into
mainfrom
refactor/split-cli-command-classes

Conversation

@rbcorrales
Copy link
Copy Markdown
Member

Summary

Splits includes/cli/class-wpvdb-cli.php, which defined two command classes, into one file per class:

  • includes/cli/class-embeddings-command.php -> Embeddings_Command (wpvdb embeddings)
  • includes/cli/class-jobs-command.php -> Jobs_Command (wpvdb embeddings job)

Each new file carries the same namespace WPVDB\CLI, the use WPVDB\Embedding_Enqueuer import (both classes use it), the ABSPATH + WP_CLI guards, and its own WP_CLI::add_command() registration. The WP_CLI-gated require in wpvdb.php now loads both files. The old file is removed.

Background

class-wpvdb-cli.php held two WP_CLI_Command classes, which trips the one-class-per-file structural sniff. Splitting clears that and makes each command easier to find. No command behavior, names, or signatures change.

Testing

php -l clean on both new files and wpvdb.php. phpcs improves: the original file reported 1 error + 2 warnings; each new file reports 0 errors + 1 (pre-existing) warning, and wpvdb.php is clean. Command registrations are preserved verbatim.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

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

Refactors the WPVDB WP-CLI integration by splitting the embeddings-related CLI commands into separate files (one class per file) and updating the plugin bootstrap to load the new command definitions when running under WP-CLI.

Changes:

  • Updated wpvdb.php to load the two new CLI command class files under the WP_CLI guard.
  • Added includes/cli/class-jobs-command.php containing Jobs_Command and its wpvdb embeddings job registration.
  • Updated includes/cli/class-embeddings-command.php to contain only Embeddings_Command and its wpvdb embeddings registration (removing the jobs command class from this file).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
wpvdb.php Loads the split CLI command files (class-embeddings-command.php, class-jobs-command.php) when WP_CLI is active.
includes/cli/class-embeddings-command.php Keeps Embeddings_Command and registers wpvdb embeddings; removes the jobs-related command class from this file.
includes/cli/class-jobs-command.php Defines Jobs_Command and registers wpvdb embeddings job.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rbcorrales rbcorrales merged commit a2711c8 into main May 27, 2026
1 check passed
@rbcorrales rbcorrales deleted the refactor/split-cli-command-classes branch May 27, 2026 23:37
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