Closed baizmandesign closed 1 year ago
Thanks for the suggestion, @baizmandesign !
create a new command to determine whether an alias is a group:
wp cli alias is-group
(returns 0 on true, 1 on false).
I'd be open to this if you'd like to submit a pull request for it.
@danielbachhuber Sounds good! I'll cook up a PR shortly.
Feature Request
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:
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":
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 aswp core is-installed
orwp plugin is-active
). Orwp 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.