Skip to content

Fix: Correct option parameter parsing in ConsoleStrategy#26

Merged
alexstandiford merged 5 commits into
mainfrom
issue/25
Jan 12, 2026
Merged

Fix: Correct option parameter parsing in ConsoleStrategy#26
alexstandiford merged 5 commits into
mainfrom
issue/25

Conversation

@alexstandiford
Copy link
Copy Markdown
Contributor

Problem:
The signature parser was only trimming a single leading dash from option parameters instead of both dashes, causing parameter names like --count to become -count. This resulted in WP-CLI generating invalid synopsis entries with three dashes (e.g., ---count) and emitting warnings.

Solution:
Changed line 112 in ConsoleStrategy::parseSignature() to trim both leading dashes (--) instead of just one (-). This ensures option parameter names are correctly extracted from signature strings.

Testing:

  • Verified with signatures containing multiple option types: {--flag}, {--option=default}, {--option=:Description}
  • Confirmed WP-CLI synopsis warnings are resolved
  • Validated that commands continue to function correctly with proper parameter resolution

Files changed:

  • lib/Strategies/ConsoleStrategy.php (line 112)

Related:
The bug was discovered while implementing test data generators using PHPNomad Console integration. The fix ensures that option parameters in command signatures are correctly parsed and registered with WP-CLI.


This fix is backwards compatible and doesn't change any API contracts - it simply corrects the internal parsing logic to match the documented signature format from PHPNomad\Console\Interfaces\Command::getSignature().

Copy link
Copy Markdown

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 fixes a bug in the ConsoleStrategy's signature parser where option parameters were incorrectly parsed. The parser was only trimming a single leading dash instead of both dashes from option names, causing invalid WP-CLI synopsis entries with three dashes and emitting warnings.

Changes:

  • Updated line 112 in ConsoleStrategy::parseSignature() to trim both leading dashes (--) instead of just one (-)

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

Comment thread lib/Strategies/ConsoleStrategy.php
Copy link
Copy Markdown

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.


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

@alexstandiford alexstandiford merged commit e38648e into main Jan 12, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants