Skip to content

Conversation

Copy link

Copilot AI commented Nov 2, 2025

Add --no-interaction flag to package commands to prevent interactive prompts

  • Add --no-interaction flag to wp package install command
  • Add --no-interaction flag to wp package update command
  • Add --no-interaction flag to wp package uninstall command
  • Set GIT_TERMINAL_PROMPT=0 environment variable when flag is used
  • Set GIT_SSH_COMMAND=ssh -o BatchMode=yes when flag is used
  • Update command documentation with new option
  • Add tests for the new option
  • Document method parameters and putenv() usage
  • Change flag to interaction with default true (WP-CLI converts --no-interaction to --interaction=false)
  • Keep --no-interaction usage in tests
  • Fix test to use real package name from package index

Implementation Details

The flag is implemented as interaction with a default value of true:

  • Code checks for interaction flag with default true
  • When interaction is false, non-interactive mode is enabled
  • Tests use --no-interaction which WP-CLI automatically converts to --interaction=false
  • Documentation uses [--interaction] syntax

Test Fix

Changed the install test to use wp-cli/restful instead of wp-cli/test-package. The package name must match a real package in the package index, as the code validates against it.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add option to be non-interactive.</issue_title>
<issue_description>See #60 (review)

Composer supports being run non-interactively so it could be useful to have an option to set this.

In particular it would avoid getting prompted for one's ssh password as can happen depending on one's authorization settings, which is problematic for scripts.</issue_description>

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

@schlessera Yes, agree, we can simply forward such an option. It's an easy addition.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 2, 2025 15:36
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] Add option for non-interactive mode Add --no-interaction flag to prevent Git/SSH prompts in package commands Nov 2, 2025
Copilot AI requested a review from swissspidy November 2, 2025 15:42
@codecov
Copy link

codecov bot commented Nov 2, 2025

Codecov Report

❌ Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Package_Command.php 0.00% 15 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy

This comment was marked as resolved.

… in tests

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

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.

Copy link

Copilot AI left a 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 --interaction flag (default: true) to install, update, and uninstall commands
  • 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 );
Copy link

Copilot AI Dec 19, 2025

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.

Suggested change
$interaction = Utils\get_flag_value( $assoc_args, 'interaction', true );
$interaction = (bool) Utils\get_flag_value( $assoc_args, 'interaction', true );

Copilot uses AI. Check for mistakes.
*/
public function update() {
public function update( $_, $assoc_args = [] ) {
$interaction = Utils\get_flag_value( $assoc_args, 'interaction', true );
Copy link

Copilot AI Dec 19, 2025

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.

Suggested change
$interaction = Utils\get_flag_value( $assoc_args, 'interaction', true );
$interaction = (bool) Utils\get_flag_value( $assoc_args, 'interaction', true );

Copilot uses AI. Check for mistakes.

$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 );
Copy link

Copilot AI Dec 19, 2025

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.

Suggested change
$interaction = Utils\get_flag_value( $assoc_args, 'interaction', true );
$interaction = (bool) Utils\get_flag_value( $assoc_args, 'interaction', true );

Copilot uses AI. Check for mistakes.
swissspidy and others added 3 commits December 19, 2025 13:26
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>
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.

Add option to be non-interactive.

2 participants