Skip to content

Extend Commands Cookbook with PHPDoc edge-cases: aliases, repeating flags, sensitive args, global arg conflicts#630

Merged
swissspidy merged 2 commits intomainfrom
copilot/extend-documentation-phpdoc-commands
Mar 17, 2026
Merged

Extend Commands Cookbook with PHPDoc edge-cases: aliases, repeating flags, sensitive args, global arg conflicts#630
swissspidy merged 2 commits intomainfrom
copilot/extend-documentation-phpdoc-commands

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 17, 2026

The Commands Cookbook lacked documentation for several PHPDoc features around argument definition edge-cases, leaving command authors to discover behavior through trial and error.

Added documentation

Repeating flags ([--status=<status>...])

When ellipsis syntax is used, passing the same flag multiple times collects values into an array ($assoc_args['status'] === ['active', 'inactive']). Without ..., repeated flags use last-wins. Boolean flags always use last-wins regardless.

Argument aliases ([--with-dependencies|w])

Pipe-separated aliases in the synopsis token map alternative names to the canonical key in $assoc_args. Works for flags, single-char short-forms, and value-carrying args:

 * [--with-dependencies|w]
 * [--verbose|v|wordy]
 * [--format=<format>|f]

Sensitive arguments (sensitive: true)

New YAML annotation in the parameter block. When --prompt is used, WP-CLI redacts the value in the echoed command line ([REDACTED]):

 * [--******
 * ---
 * sensitive: true
 * ---

@skipglobalargcheck docblock tag

WP-CLI now warns at registration time when a command argument name collides with a global argument (--debug, --user, --quiet, etc.). Add @skipglobalargcheck to the PHPdoc to suppress the warning intentionally.

Original prompt

This section details on the original issue you should resolve

<issue_title>Extends documentation about commands' phpdoc possibilities/limitations</issue_title>
<issue_description>- [x] Yes, I reviewed the contribution guidelines.

Describe your use case and the problem you are facing

Commands cookbook is lacking some edge-cases about commands' options and I didn't find my answer in any other place either.

Describe the solution you'd like

I'd like to find answers to the following topics regarding phpdoc definition of a command:

  1. Handling short option. Why aren't they supported? Is there known workarounds?
  2. Handling options expecting a comma-separated list of values (like in --foo=bar,baz). It's another common case and I failed to find any example. It's sad options couldn't be used and one can't know if some utils already exist within wp-cli to handle them.
  3. Multiple occurrences of the same option (like in --regex=ab --regex=cd) is another case where documentation is lacking.
    </issue_description>

<agent_instructions>Document the new API additions to the Commands cookbook docs:

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

@swissspidy Short options will be supported by https://github.com/wp-cli/wp-cli/pull/6176 if we decide to add it.

2 and 3 are covered by wp-cli/wp-cli#6198

wp-cli/wp-cli#6145 is another good addition for the documentation

wp-cli/wp-cli#6174 too</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Extend documentation about commands' phpdoc possibilities/limitations Extend Commands Cookbook with PHPDoc edge-cases: aliases, repeating flags, sensitive args, global arg conflicts Mar 17, 2026
Copilot AI requested a review from swissspidy March 17, 2026 16:40
@swissspidy swissspidy marked this pull request as ready for review March 17, 2026 17:05
@swissspidy swissspidy requested a review from a team as a code owner March 17, 2026 17:05
Copilot AI review requested due to automatic review settings March 17, 2026 17:05
@swissspidy swissspidy merged commit a80feed into main Mar 17, 2026
8 checks passed
@swissspidy swissspidy deleted the copilot/extend-documentation-phpdoc-commands branch March 17, 2026 17:06
Copy link
Copy Markdown
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 expands the WP-CLI Commands Cookbook documentation to cover additional PHPDoc/synopsis edge-cases and metadata that affect how command arguments are parsed and validated.

Changes:

  • Documented repeating associative flags via ellipsis ([--status=<status>...]) and clarified last-wins behavior.
  • Added documentation for synopsis argument aliases using | (including short forms).
  • Added documentation for sensitive: true YAML parameter metadata and the @skipglobalargcheck docblock tag.

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

You can also share your feedback on Copilot code review. Take the survey.


**@skipglobalargcheck**

WP-CLI emits a warning at command-registration time if a command defines an argument whose name collides with an existing [global argument](https://make.wordpress.org/cli/handbook/config/) (e.g. `--debug`, `--user`, `--quiet`). This helps command authors avoid confusing behaviour where the global argument takes precedence over the command-specific one.
* `[--field[=<value>]]` allows an optional argument to be used with or without a value. An example of this would be using a global parameter like `--skip-plugins[=<plugins>]` which can either skip loading all plugins, or skip a comma-separated list of plugins.
* `[--field[=<value>]]` allows an optional argument to be used with or without a value. An example of this would be using a global parameter like `--skip-plugins[=<plugins>]` which can either skip loading all plugins, or skip a comma-separated list of plugins.
* `[--status=<status>...]` (note the trailing `...`) declares a **repeating** associative argument.
* When the same flag is passed more than once (e.g. `--status=active --status=inactive`), WP-CLI collects the values into an array and `$assoc_args['status']` will be `[ 'active', 'inactive' ]`.
* `[--field[=<value>]]` allows an optional argument to be used with or without a value. An example of this would be using a global parameter like `--skip-plugins[=<plugins>]` which can either skip loading all plugins, or skip a comma-separated list of plugins.
* `[--status=<status>...]` (note the trailing `...`) declares a **repeating** associative argument.
* When the same flag is passed more than once (e.g. `--status=active --status=inactive`), WP-CLI collects the values into an array and `$assoc_args['status']` will be `[ 'active', 'inactive' ]`.
* Without the `...` ellipsis, passing the same flag multiple times uses **last-wins** behaviour—only the final value is kept.
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.

Extends documentation about commands' phpdoc possibilities/limitations

3 participants