-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Feature Request
- Yes, I reviewed the contribution guidelines.
Describe your use case and the problem you are facing
I'd like to be able to differentiate between the two types of WP CLI aliases: ones that resolve to a single site's definition (which we'll call a "singleton" alias), and ones that resolve to one or more aliases (which we'll call a "group" alias). This would be useful for scripting purposes.
An example might help. Let's say that I have the following aliases:
@one:
ssh: one.org
path: public_html
@two:
ssh: two.org
path: public_html
@both:
- @one
- @two
Now let's say that one is a single instance of WordPress, and two is a multi-site instance of WordPress. There are a number of commands that require an extra flag to work on a multi-site ("--network"). For example, activating a plugin. The following command will succeed for "one" and fail for "two":
$ wp @both plugin activate some-plugin
It fails for "two" because it lacks the "--network" flag.
Describe the solution you'd like
I know I can use the shell and grep to address this problem, but it would be nice if it were addressed in WP CLI itself.
I have one proposal in two flavors: create a new command to determine whether an alias is a group: wp cli alias is-group
(returns 0 on true, 1 on false). This is similar to other commands such as wp core is-installed
or wp plugin is-active
). Or wp cli alias get-type
(returns string "group" or "single"). With this command in a script, some conditional processing can be done when dealing with either a singleton or group alias.