refactor: split CLI command classes into separate files#15
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
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.phpto load the two new CLI command class files under theWP_CLIguard. - Added
includes/cli/class-jobs-command.phpcontainingJobs_Commandand itswpvdb embeddings jobregistration. - Updated
includes/cli/class-embeddings-command.phpto contain onlyEmbeddings_Commandand itswpvdb embeddingsregistration (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.
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
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, theuse WPVDB\Embedding_Enqueuerimport (both classes use it), theABSPATH+WP_CLIguards, and its ownWP_CLI::add_command()registration. TheWP_CLI-gated require inwpvdb.phpnow loads both files. The old file is removed.Background
class-wpvdb-cli.phpheld twoWP_CLI_Commandclasses, 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 -lclean on both new files andwpvdb.php. phpcs improves: the original file reported 1 error + 2 warnings; each new file reports 0 errors + 1 (pre-existing) warning, andwpvdb.phpis clean. Command registrations are preserved verbatim.🤖 Generated with Claude Code