Skip to content

Try support PowerShell#93

Draft
swissspidy wants to merge 5 commits intomainfrom
try/windows
Draft

Try support PowerShell#93
swissspidy wants to merge 5 commits intomainfrom
try/windows

Conversation

@swissspidy
Copy link
Copy Markdown
Member

No description provided.

@github-actions
Copy link
Copy Markdown
Contributor

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Here are some useful Composer commands to get you started:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

To run a single Behat test, you can use the following command:

# Run all tests in a single file
composer behat features/some-feature.feature

# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123

You can find a list of all available Behat steps in our handbook.

@github-actions github-actions bot added command:shell Related to 'shell' command scope:testing Related to testing state:unconfirmed labels Mar 28, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces Windows support for the WP-CLI shell by utilizing powershell.exe and Read-Host. Feedback highlights a lack of command history support in the new PowerShell implementation, which is a regression compared to other shells. Additionally, the removal of the shell binary validation check for non-PowerShell environments should be restored to ensure proper error handling for custom shell configurations.

Comment on lines +198 to 204
if ( $is_powershell ) {
// PowerShell uses ` (backtick) for escaping but for strings single quotes are literal.
// If prompt contains single quotes, we double them in PowerShell.
$prompt_for_ps = str_replace( "'", "''", $prompt );
$cmd = "\$line = Read-Host -Prompt '{$prompt_for_ps}'; Write-Output \$line;";
return "powershell.exe -NoProfile -Command \"{$cmd}\"";
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The new PowerShell implementation provides basic REPL functionality, but it's missing command history support, which is a crucial feature for an interactive shell. The use of Read-Host with the -NoProfile switch on powershell.exe prevents the use of PSReadLine for history. This is a significant usability regression compared to the bash/ksh implementation which explicitly handles a history file.

Please consider implementing history support for PowerShell. This could involve:

  • Manually managing a history file with PowerShell commands (e.g., Get-Content/Add-Content).
  • Interacting with the PSReadLine module's history functions if it's available.

Without history, the shell is much less productive.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

❌ Patch coverage is 54.54545% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/WP_CLI/Shell/REPL.php 54.54% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

Labels

command:shell Related to 'shell' command scope:testing Related to testing state:unconfirmed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant