Open
Conversation
- Extended DocParser to parse 'alias' metadata from PHPdoc parameters - Updated Subcommand to resolve aliases to canonical names before validation - Modified Configurator to support single-dash short arguments (e.g., -w, -n=5) - Added comprehensive unit tests for alias resolution - Added Behat feature tests for argument aliases Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
- Store the original DocParser instance in Subcommand to access YAML metadata - Fix access level visibility issue with $synopsis property - Add debug logging for alias resolution - Verify aliases work correctly with manual testing Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
- Simplify alias resolution logic with two-pass approach - Add documentation for single-letter short argument limitation - Improve code clarity and maintainability Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for argument aliases in WP-CLI
Add support for argument aliases
Dec 20, 2025
This comment was marked as resolved.
This comment was marked as resolved.
YAML parsers interpret 'n', 'N', 'y', 'Y' as boolean values (false/true). This caused single-letter aliases like 'n' to be parsed as false and then converted to empty strings. Added special handling to convert boolean false back to 'n' and boolean true to 'y', along with proper type conversion and empty string filtering. 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.
…tation - Renamed all test methods in ArgAliasTest.php from camelCase to snake_case to match existing test conventions in the codebase - Enhanced documentation for YAML boolean value handling to explain the behavior more clearly, including the note that 'n'/'N' become 'n' and 'y'/'Y' become 'y' - Added new test case for YAML boolean handling to verify correct behavior - Mentioned that users can quote aliases in YAML to avoid boolean interpretation Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 task
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Refactored get_arg_aliases() to use a single-pass state machine instead of calling get_param_or_flag_args() for each parameter, which itself iterates over all doc comment lines. This eliminates the nested loop pattern and improves performance from O(n²) to O(n) where n is the number of doc lines. Key changes: - Parse doc comment in a single pass using state machine - Track current parameter and YAML block state - Preserve indentation in YAML blocks for correct parsing - Process aliases when YAML block ends This is especially beneficial for commands with many parameters and extensive documentation, where the nested iteration could cause noticeable performance issues during command loading. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Modified resolve_arg_aliases() to accept pre-computed aliases as a parameter
instead of fetching them internally. In invoke(), compute the alias map once
via get_arg_aliases() and reuse it for both assoc_args and extra_args.
This eliminates duplicate parsing of the PHPDoc and ensures consistent debug
output, improving performance when both argument arrays need resolution.
Also updated test_get_arg_aliases_yaml_boolean_handling to use quoted YAML
values ('n' and 'y' instead of unquoted) to work with the recent removal of
special boolean handling.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Re-added the special case handling for YAML boolean values that was previously removed. This is necessary because YAML 1.1 interprets single letters 'n', 'N', 'y', 'Y' as booleans (false/true), which when cast to strings become empty or '1', breaking alias registration. Without this handling, aliases like `alias: n` fail to work because: 1. YAML parses 'n' as boolean false 2. (string)false becomes '' 3. Empty string is filtered out, no alias registered The fix converts boolean false back to 'n' and boolean true back to 'y', allowing common single-letter aliases to work without requiring quotes. This fixes the failing Behat test for `-n=42` alias usage. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Member
|
Possible alternative syntax: |
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.
Implementation Plan for Argument Aliases
Understand the existing codebase structure for argument handling
Extend DocParser to support parsing argument aliases from PHPdoc
Implement alias resolution logic
Handle short-form aliases (single character with
-)Add comprehensive tests
Run all tests and fix any issues
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.