Extend Commands Cookbook with PHPDoc edge-cases: aliases, repeating flags, sensitive args, global arg conflicts#630
Merged
swissspidy merged 2 commits intomainfrom Mar 17, 2026
Conversation
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
Contributor
There was a problem hiding this comment.
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: trueYAML parameter metadata and the@skipglobalargcheckdocblock 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:Sensitive arguments (
sensitive: true)New YAML annotation in the parameter block. When
--promptis used, WP-CLI redacts the value in the echoed command line ([REDACTED]):@skipglobalargcheckdocblock tagWP-CLI now warns at registration time when a command argument name collides with a global argument (
--debug,--user,--quiet, etc.). Add@skipglobalargcheckto the PHPdoc to suppress the warning intentionally.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.