-
Notifications
You must be signed in to change notification settings - Fork 18
Add --no-interaction flag to prevent Git/SSH prompts in package commands #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This comment was marked as resolved.
This comment was marked as resolved.
… in tests Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a --no-interaction flag to WP-CLI package commands to prevent interactive prompts during Git/SSH operations, which is essential for scripting and automation. The implementation sets environment variables (GIT_TERMINAL_PROMPT=0 and GIT_SSH_COMMAND=ssh -o BatchMode=yes) to disable credential prompts.
Key changes:
- Added
--interactionflag (default: true) toinstall,update, anduninstallcommands - Created
set_non_interactive_mode()method to configure Git/SSH environment variables - Added Behat test scenarios for all three commands to verify the flag works correctly
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/Package_Command.php | Added --interaction flag handling to install(), update(), and uninstall() methods; implemented set_non_interactive_mode() helper method; updated method signatures and documentation |
| features/package.feature | Added test scenario for uninstall command with --no-interaction flag |
| features/package-update.feature | Added test scenario for update command with --no-interaction flag |
| features/package-install.feature | Added test scenario for install command with --no-interaction flag using a local dummy package |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| $insecure = (bool) Utils\get_flag_value( $assoc_args, 'insecure', false ); | ||
| $insecure = (bool) Utils\get_flag_value( $assoc_args, 'insecure', false ); | ||
| $interaction = Utils\get_flag_value( $assoc_args, 'interaction', true ); |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interaction flag should be explicitly cast to boolean like the insecure flag on line 602 for consistency and type safety. While Utils\get_flag_value returns a boolean-ish value, explicit casting makes the intent clear and ensures consistent behavior.
| $interaction = Utils\get_flag_value( $assoc_args, 'interaction', true ); | |
| $interaction = (bool) Utils\get_flag_value( $assoc_args, 'interaction', true ); |
| */ | ||
| public function update() { | ||
| public function update( $_, $assoc_args = [] ) { | ||
| $interaction = Utils\get_flag_value( $assoc_args, 'interaction', true ); |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interaction flag should be explicitly cast to boolean for consistency with how the insecure flag is handled elsewhere in this file (lines 222, 602) and for type safety.
| $interaction = Utils\get_flag_value( $assoc_args, 'interaction', true ); | |
| $interaction = (bool) Utils\get_flag_value( $assoc_args, 'interaction', true ); |
|
|
||
| $insecure = (bool) Utils\get_flag_value( $assoc_args, 'insecure', false ); | ||
| $insecure = (bool) Utils\get_flag_value( $assoc_args, 'insecure', false ); | ||
| $interaction = Utils\get_flag_value( $assoc_args, 'interaction', true ); |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interaction flag should be explicitly cast to boolean like the insecure flag on line 222 for consistency and type safety. While Utils\get_flag_value returns a boolean-ish value, explicit casting makes the intent clear and ensures consistent behavior.
| $interaction = Utils\get_flag_value( $assoc_args, 'interaction', true ); | |
| $interaction = (bool) Utils\get_flag_value( $assoc_args, 'interaction', true ); |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add
--no-interactionflag to package commands to prevent interactive prompts--no-interactionflag towp package installcommand--no-interactionflag towp package updatecommand--no-interactionflag towp package uninstallcommandGIT_TERMINAL_PROMPT=0environment variable when flag is usedGIT_SSH_COMMAND=ssh -o BatchMode=yeswhen flag is usedinteractionwith defaulttrue(WP-CLI converts --no-interaction to --interaction=false)Implementation Details
The flag is implemented as
interactionwith a default value oftrue:interactionflag with defaulttrueinteractionisfalse, non-interactive mode is enabled--no-interactionwhich WP-CLI automatically converts to--interaction=false[--interaction]syntaxTest Fix
Changed the install test to use
wp-cli/restfulinstead ofwp-cli/test-package. The package name must match a real package in the package index, as the code validates against it.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.