Repository navigation
Discoverability for fourth level commands provided by plugins - #642
danielbachhuber wants to merge 4 commits into
Conversation
|
Another option would be to split the event subcommands into a separate top-level command, which will give you:
|
|
Coincidentally enough, I've been meaning to open a discussion on the same exact topic. We have the same need for https://github.com/humanmade/wp-cli-remote-command, which currently has commands like:
I don't have a good technical recommendation on how to achieve this. The primary value in my mind is usability. On a similar note, it would be nice to be able to manually sort the order of appearance for subcommands, instead of alphabetical. |
|
From an API perspective, it could be as simple as: WP_CLI::add_command( 'crontrol event', 'CrontrolEventCommand' ); |
|
Note that this would also open the door for attaching additional subcommands to built-in commands: class PluginGithubCommand extends WP_CLI_Command {
function __invoke( $args, $assoc_args ) {
// Do it.
}
}
WP_CLI::add_command( 'plugin install-github', 'PluginGithubCommand' ); |
…like `wp remote option` Doesn't yet work for fifth-level commands
|
Functional prototype time! I've changed the internals of With a command like
As far as I can tell (and what the tests can tell me), this doesn't break the internals. There's one side effect though: If none of those commands are registered, then our error reporting gets a little wonky (strongly related to #782). I can't think of a good way to detect whether your mistyped command correlates with a top-level command, second-level command, third-level command, etc., so I changed the behavior to this for now: Open questions:
|
|
First of all, let's set some ground rules:
Yes, regardless if
I don't see why not.
Yes, even if there's no description. Or maybe we need a new method for adding descriptions to containers.
I think this is the trickiest question. TBD |
So, if I pass a thousand IDs to |
Yeah. Other ideas? |
|
Well, the other idea would be to descend from the root command, as it's currently done. |
|
Just wanted to update that this is on my radar again. I'd like for it to go out when the package command goes out, as they compliment each other nicely. |
|
Taking a stab at this. |

Most of the core commands in WP-CLI are third-level commands in the format
wp [singular-noun] [action]Example:
wp post createI want the commands provided by my plugin to follow this pattern, but prefixed with the plugin name. Each command becomes a fourth-level command. Example:
wp crontrol event listandwp crontrol event deleteThe problem is I can't use this format because a fourth-level command isn't discoverable via
wp crontrol. It'll only listwp crontrol eventas an available command, and the user needs to typewp help crontrol eventin order to see the available event commands. Tab completion isn't available for fourth level commands either.My plugin currently implements the commands thus:
wp crontrol list-eventsandwp crontrol delete-eventwhich is less than ideal because it deviates from WP-CLI's conventions for command naming.
What can be done to improve this?