Skip to content

Comments

Add restart command and --watch option to wp shell#77

Open
Copilot wants to merge 14 commits intomainfrom
copilot/support-restarting-shell
Open

Add restart command and --watch option to wp shell#77
Copilot wants to merge 14 commits intomainfrom
copilot/support-restarting-shell

Conversation

Copy link
Contributor

Copilot AI commented Oct 30, 2025

  • Implement restart functionality in REPL class
  • Implement wrapper loop in Shell_Command to restart REPL
    • Spawn new PHP process using pcntl_exec() to fully reload all code
    • Simplify WP-CLI script path detection (if/elseif instead of foreach)
    • Use WP_CLI::get_runner()->config for robust --path, --user, --url preservation
  • Add comprehensive tests for restart and exit functionality
  • Implement --watch option for auto-restart on file changes
  • Update documentation in docblocks with examples
  • Fix PHPCS alignment issues
  • Remove unnecessary PHPStan ignore directive
  • Add SplFileInfo type hint for PHPStan
Original prompt

This section details on the original issue you should resolve

<issue_title>Support restarting a shell</issue_title>
<issue_description>The wp shell command is super useful for debugging sessions, however it is quite tedious when you need to make code changes, as it does not reload the modified code.

By properly spawning the actual REPL in a new PHP process, and by checking the exit state for a specific result, it should be possible to inject a command that allows for restarting the REPL.

Bonus points: provide a wp shell --watch=<folder> command that watches for changes in a specific folder and restarts the shell automatically.</issue_description>

Comments on the Issue (you are @copilot in this section)

@danielbachhuber 💯

💡 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.

Copilot AI and others added 3 commits October 30, 2025 12:22
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
Copilot AI requested a review from swissspidy October 30, 2025 12:31
@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 14.60674% with 76 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Shell_Command.php 16.32% 41 Missing ⚠️
src/WP_CLI/Shell/REPL.php 12.50% 35 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy swissspidy marked this pull request as ready for review October 30, 2025 21:25
@swissspidy swissspidy requested a review from a team as a code owner October 30, 2025 21:25

This comment was marked as resolved.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support restarting a shell

2 participants