Improve help screens: show disabled commands with reason and add --full recursive help#6287
Conversation
- Show disabled commands in help listings with a '(disabled)' indicator instead of silently hiding them. This applies to both `wp help <cmd>` subcommand listings and `wp <cmd>` usage listings. - Add `--full` flag to `wp help` that recursively shows help for the command and all its non-disabled subcommands, separated by '---' dividers. Useful for a 'man page'-style view of all commands. - Refactor show_help() to extract get_help_as_string() helper for reuse. - Update Behat tests to reflect new disabled command behavior, and add new scenarios for both features. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> Agent-Logs-Url: https://github.com/wp-cli/wp-cli/sessions/7f17cb62-25d6-4243-902b-b91c72b3a439
This comment was marked as resolved.
This comment was marked as resolved.
Add get_command_disabled_reason() to Runner that returns the reason why a command is disabled (e.g. "from the config file") or false if it isn't. Refactor is_command_disabled() to delegate to this new method. Update render_subcommands() in Help_Command and show_usage() in CompositeCommand to display the reason: "(disabled: from the config file)" instead of just "(disabled)". Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> Agent-Logs-Url: https://github.com/wp-cli/wp-cli/sessions/390953ed-6fff-4d07-8ddd-cba8679902e6
This comment was marked as resolved.
This comment was marked as resolved.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Improves WP‑CLI help UX by making disabled commands visible (with an explanation) and adding a wp help --full mode to recursively print help for a command tree in a single, pager-friendly output.
Changes:
- Show disabled commands in help/usage output, including a reason instead of omitting them.
- Add
--fulltowp helpto recursively include help for subcommands. - Refactor help rendering to support accumulating output as a string before paging.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| php/commands/src/Help_Command.php | Adds --full, refactors help rendering into string helpers, and updates subcommand listing to include disabled entries with reasons. |
| php/class-wp-cli.php | Wraps aborted command additions in a DisabledCommand so they can appear in listings while remaining non-invokable. |
| php/WP_CLI/Runner.php | Introduces get_command_disabled_reason() and refactors is_command_disabled() to delegate to it. |
| php/WP_CLI/Dispatcher/DisabledCommand.php | New dispatcher command type representing a disabled command and preventing execution with a dedicated error. |
| php/WP_CLI/Dispatcher/CompositeCommand.php | Updates composite usage output to show disabled subcommands with a suffix. |
| features/help.feature | Adds coverage for disabled-command visibility and --full recursive output. |
| features/config.feature | Updates expectations so config-disabled commands appear in listings with the reason. |
| features/command.feature | Updates expectations so hook-aborted commands appear in command listings with their docs/reason. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request enhances WP-CLI's handling of disabled commands by ensuring they are visible in help listings along with the reason for their disablement. It introduces a new DisabledCommand class, updates the add_command logic to retain aborted commands as disabled instances, and adds a --full flag to the wp help command for recursive subcommand documentation. I have no feedback to provide.
Disabled commands were silently hidden from help listings, making it hard to understand why a command seemed to be missing. There was also no way to get a comprehensive view of all subcommands and their documentation in one place.
Changes
Show disabled commands with reason in help listings
CompositeCommand::show_usage()— disabled subcommands now appear with the reason appended rather than being omitted (affectswp core,wp db, etc.)Help_Command::render_subcommands()— theSUBCOMMANDSsection inwp help <cmd>now lists disabled commands with the reason includedRunner::get_command_disabled_reason()— new method returning the reason why a command is disabled (e.g."from the config file") orfalseif it isn't;is_command_disabled()now delegates to itExample:
Trying to run or get detailed help on a disabled command still errors as before. Example:
wp help --fullfor recursive help outputAdds a
--fullflag towp helpthat recursively outputs help for the specified command and all its non-disabled subcommands, separated by---dividers — a man-page-style overview of the entire command tree.Internal refactor
show_help()is now a thin wrapper around the extractedget_help_as_string()helper, whichget_help_full()uses to accumulate output before a single pager pass.Test updates
features/config.feature: updated assertions to verify(disabled: from the config file)appears in listingsfeatures/help.feature: new scenarios for disabled-command visibility with reason and--fullbehaviorOriginal prompt
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.