Skip to content

Initial implementation of command namespaces.#4470

Merged
danielbachhuber merged 4 commits intomasterfrom
4385-add-command-namespace
Oct 30, 2017
Merged

Initial implementation of command namespaces.#4470
danielbachhuber merged 4 commits intomasterfrom
4385-add-command-namespace

Conversation

@schlessera
Copy link
Member

A command namespace is a command placeholder that can receive annotations, sub-commands and all other shenanigans that a normal composite command can have, with the following changes:

  • A namespace will never replace a previously added command of the same name.
  • A namespace will always be replaced by a command of the same name that is added later.
  • An empty namespace shows a corresponding notice when invoked.

See #4385

A command namespace is a command placeholder that can receive annotations, sub-commands and all other shenanigans that a normal composite command can have, with the following changes:

* A namespace will never replace a previously added command of the same name.
* A namespace will always be replaced by a command of the same name that is added later.
* An empty namespace shows a corresponding notice when invoked.

See #4385
@schlessera schlessera requested a review from a team October 29, 2017 13:41
Copy link
Member

@miya0001 miya0001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😊

* @param string $name Represents how the command should be invoked
* @param mixed $callable
*/
private static function create_namespace( $parent, $name, $callable ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we enforce any specific characteristics of the class (e.g. no defined methods, must extend some base class, etc.)?

Also, what happens if this isn't a class? WP_CLI::add_command() accepts any callable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a private helper method. The $callable was already checked before to assert that it is a subclass of the namespace class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah :)

@danielbachhuber danielbachhuber merged commit 32f2247 into master Oct 30, 2017
@danielbachhuber danielbachhuber deleted the 4385-add-command-namespace branch October 30, 2017 17:39
@danielbachhuber danielbachhuber added this to the 1.5.0 milestone Oct 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants