Add restart command and --watch option to wp shell#77
Open
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Support restarting the shell in wp shell command
Add restart command and --watch option to wp shell
Oct 30, 2025
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
swissspidy
reviewed
Oct 30, 2025
swissspidy
reviewed
Oct 30, 2025
There was a problem hiding this comment.
Pull request overview
This PR adds restart functionality and a file watching feature to the wp shell command. The restart command allows users to reset the REPL state, and the --watch option automatically restarts the shell when files change in a specified directory.
Changes:
- Added
restartandexitcommands to the built-in REPL - Implemented
--watchoption to monitor file changes and auto-restart - Added comprehensive Behat tests for restart and exit commands
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/WP_CLI/Shell/REPL.php | Implements restart/exit command detection, file watching logic with recursive directory scanning, and returns appropriate exit codes |
| src/Shell_Command.php | Adds --watch parameter handling, implements restart loop wrapper, forces --basic mode for watch functionality, and validates watch paths |
| features/shell.feature | Adds test scenarios for restart and exit commands to ensure proper functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
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.
Implementation Complete
The
restartcommand now spawns a new PHP process usingpcntl_exec(), which fully reloads all code including files loaded withrequire_once/include_once. This addresses the original issue requirement to "properly spawn the actual REPL in a new PHP process" for reloading modified code. Ifpcntl_exec()is not available, the shell falls back to in-process restart with a debug message.All requirements from the issue have been implemented and code style issues have been addressed.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.