Skip to content

Add support for multiple flag values via repeated flags using ellipsis syntax#6198

Open
Copilot wants to merge 8 commits intomainfrom
copilot/add-multiple-status-support
Open

Add support for multiple flag values via repeated flags using ellipsis syntax#6198
Copilot wants to merge 8 commits intomainfrom
copilot/add-multiple-status-support

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

Implementation Complete: Multiple Flag Values Support ✅

This PR implements support for passing the same flag multiple times to provide multiple values, addressing issue #159. Users can now use --status=active --status=parent instead of being limited to comma-separated values.

Core Changes

  • ✅ Modified Configurator::unmix_assoc_args() to collect multiple flag values into arrays
  • ✅ Updated Subcommand::validate_args() to handle repeating parameters using ellipsis syntax
  • ✅ Added validation for array values with improved error messages
  • ✅ Full backward compatibility maintained
  • ✅ Applied code review feedback: modern array destructuring, avoided end() side effects
  • ✅ Uses existing ellipsis syntax (...) consistent with repeating positional parameters

Testing & Quality

  • ✅ Unit tests (6/6 pass in ConfiguratorTest)
  • ✅ Feature tests (3 scenarios, 24 steps, all pass)
  • ✅ Added test for invalid value appearing first in array
  • ✅ Linting, phpcs pass
  • ✅ CodeQL security scan (no issues)

Usage Example

# NEW: Use repeated flags
wp theme list --status=active --status=parent

# STILL WORKS: Comma-separated
wp theme list --status=active,parent

# STILL WORKS: Single value  
wp theme list --status=active

How to Add to Your Command

Use the ellipsis syntax in the synopsis (same as for repeating positional parameters):

/**
 * [--status=<status>...]
 * : Filter by status
 * ---
 * options:
 *   - active
 *   - inactive
 * ---
 */

This leverages the existing $spec['repeating'] attribute from SynopsisParser, which already detects the ellipsis and works with infrastructure like prompt_args().

Follow-up Required

The changes in vendor files (Theme_Command.php, Plugin_Command.php, CommandWithUpgrade.php) need to be submitted to the wp-cli/extension-command repository separately. See MULTIPLE_FLAG_VALUES_IMPLEMENTATION.md for details.

Files Changed

  • php/WP_CLI/Configurator.php - Argument parsing with modern array destructuring
  • php/WP_CLI/Dispatcher/Subcommand.php - Validation logic using $spec['repeating']
  • tests/ConfiguratorTest.php - Unit tests
  • features/multiple-flag-values.feature - Feature tests with ellipsis syntax
  • MULTIPLE_FLAG_VALUES_IMPLEMENTATION.md - Documentation
Original prompt

This section details on the original issue you should resolve

<issue_title>wp theme list show multiple status</issue_title>
<issue_description>I am creating an audit script and noticed that you cannot use more than one status with the wp theme list command.

Here is an example on a live site:

wp theme list

Output

+----------------+--------+--------+---------+
| name           | status | update | version |
+----------------+--------+--------+---------+
| woodmart-child | active | none   | 1.0.0   |
| woodmart       | parent | none   | 4.4.0   |
+----------------+--------+--------+---------+

I can filter by one status

wp theme list --status=active

Output

+----------------+--------+--------+---------+
| name           | status | update | version |
+----------------+--------+--------+---------+
| woodmart-child | active | none   | 1.0.0   |
+----------------+--------+--------+---------+

But if I try to get both the active and parent status in one command it fails

wp theme list --status=active,parent

Output

+------+--------+--------+---------+
| name | status | update | version |
+------+--------+--------+---------+
+------+--------+--------+---------+

</issue_description>

<agent_instructions>Similar to the senstive: true annotation, there could be one called multiple: true. Then, when parsing arguments, if doing something like --flag=foo --flag=bar, if multiple: true is set, $assoc_args['flag'] would be an array [ 'foo', 'bar' ]</agent_instructions>

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

@swissspidy Sounds like it might be looking for a status called `active,parent` and not actually doing any splitting to filter by both.

So this would be more of an enhancement. I'd be open to accept a PR that covers all relevant commands and also clearly documents the behavior. Would also be good to check other commands as well to ensure they all behave similarly.</comment_new>
<comment_new>@thelovekesh
@swissspidy IMO It's hard to guess whether the user wants to pass comma-separated strings as multiple strings or the string itself contains the comma. In this case, we can explore the strategy to pass a flag multiple times in case multiple values are intended for a flag.

Example:

$ wp --flag=option1 --flag=option2
# It will be parsed by CLI as `$flag = [ 'option1', 'option2' ]`

$ wp --flag=option1,option2
# It will be parsed by CLI as `$flag = [ 'option1,option2' ]`
```</body></comment_new>
<comment_new><author>@danielbachhuber</author><body>
Related https://github.com/wp-cli/extension-command/issues/159</body></comment_new>
</comments>

💡 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 2 commits January 19, 2026 10:25
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI and others added 3 commits January 19, 2026 10:29
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] Add support for multiple statuses in wp theme list command Add support for multiple flag values via repeated flags Jan 19, 2026
Copilot AI requested a review from swissspidy January 19, 2026 10:33
@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 58.33333% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
php/WP_CLI/Configurator.php 16.66% 10 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

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 support for specifying multiple values for a flag by repeating it (e.g., --status=active --status=parent), addressing the inability to filter by multiple status values in commands like wp theme list.

Changes:

  • Modified argument parsing to collect repeated flags into arrays instead of overwriting values
  • Added multiple: true annotation support in PHPdoc YAML for parameters that should accept multiple values
  • Implemented backward compatibility by using the last value when multiple is not set or is false

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
php/WP_CLI/Configurator.php Collects repeated flag values into arrays during argument parsing
php/WP_CLI/Dispatcher/Subcommand.php Validates multiple flag values and preserves arrays when multiple: true is set
tests/ConfiguratorTest.php Unit test verifying multiple flag values are parsed correctly
features/multiple-flag-values.feature Feature tests for multiple values, backward compatibility, and validation
MULTIPLE_FLAG_VALUES_IMPLEMENTATION.md Documentation of implementation details and usage examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…end()

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

This comment was marked as resolved.

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

Replace the `multiple: true` annotation approach with the existing ellipsis
syntax (e.g., `[--status=<status>...]`) which is already used for repeating
positional parameters. This leverages the existing `$spec['repeating']`
attribute from SynopsisParser rather than introducing a new annotation.

Changes:
- Updated Subcommand.php to check $spec['repeating'] instead of $spec_args['multiple']
- Updated feature tests to use [--status=<status>...] syntax
- Updated documentation to reflect the ellipsis approach

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

This comment was marked as resolved.

Copilot AI changed the title Add support for multiple flag values via repeated flags Add support for multiple flag values via repeated flags using ellipsis syntax Feb 6, 2026
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.

wp theme list show multiple status

2 participants