Skip to content

Differentiate commands from namespaces in --debug output#6205

Merged
swissspidy merged 3 commits into
mainfrom
copilot/improve-debug-output-commands
Jan 22, 2026
Merged

Differentiate commands from namespaces in --debug output#6205
swissspidy merged 3 commits into
mainfrom
copilot/improve-debug-output-commands

Conversation

Copilot AI commented Jan 22, 2026

Copy link
Copy Markdown
Contributor
  • Understand the codebase and identify where debug output is generated
  • Modify debug output in WP_CLI::add_command() to differentiate between commands and namespaces
  • Add tests to verify the debug output differentiation
  • Test changes manually with --debug flag
  • Run linting and static analysis
  • Request code review
  • Run CodeQL security check
  • Address review feedback: Use imported CommandNamespace class name instead of Dispatcher\CommandNamespace for consistency with rest of codebase

Summary

Successfully implemented differentiation between commands and namespaces in --debug output. Updated to use imported class name for consistency.

Key Changes

  • Modified php/class-wp-cli.php to check if command is CommandNamespace instance (using imported class name)
  • Debug output now shows "Adding namespace:" vs "Adding command:"
  • Added Behat test to verify the behavior

Testing Results

✅ Manual testing with various scenarios (nested, multiple namespaces, regular commands)
✅ PHPCS linting passed
✅ PHPStan static analysis passed
✅ Code review feedback addressed
✅ Functionality verified after changes

Original prompt

This section details on the original issue you should resolve

<issue_title>In --debug output, differentiate between commands and namespace</issue_title>
<issue_description>When using WP_CLI::add_command, you can add either a proper command, or a command namespace, which serves as a placeholder only.

The --debug output should differentiate between these two. Right now, it only reports that it is Adding command: xyz for both.</issue_description>

<agent_instructions>There's some prior art in #5440</agent_instructions>

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

@schlessera #4985 already makes a change, but it deals with parent & child commands. This ticket is specifically about adapting the debug output for adding commands of type [`WP_CLI\Dispatcher\CommandNamespace`](https://github.com/wp-cli/wp-cli/blob/master/php/WP_CLI/Dispatcher/CommandNamespace.php), as these commands will be _replaced_ by real commands of a same name later on.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix debug output for command and namespace differentiation Differentiate commands from namespaces in --debug output Jan 22, 2026
Copilot AI requested a review from swissspidy January 22, 2026 18:21
@github-actions github-actions Bot added command:cli Related to 'cli' command command:cli-debug labels Jan 22, 2026
@codecov

This comment was marked as resolved.

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy swissspidy marked this pull request as ready for review January 22, 2026 22:01
@swissspidy swissspidy requested a review from a team as a code owner January 22, 2026 22:01
@swissspidy swissspidy added this to the 3.0.0 milestone Jan 22, 2026
@swissspidy swissspidy merged commit 790cc99 into main Jan 22, 2026
52 of 53 checks passed
@swissspidy swissspidy deleted the copilot/improve-debug-output-commands branch January 22, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:cli Related to 'cli' command command:cli-debug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In --debug output, differentiate between commands and namespace

3 participants