You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support multiple values on "plugin list --status=X" #194
I wish to find all not inactive plugins and themes for a site. If I use "wp plugin list --status=active" I'll miss any that are "active-network", and vice versa. I'm using "--format=json" so can't simply grep the output lines.
Obviously I could pass the JSON output through something like jq as a workaround, but the ability to do something like "wp plugin list --status=active,active-network" would negate the need for the extra processing. Alternatively "wp plugin --status=!inactive" or the like would also work.
Yes, some care needs to be taken with the separator or negation operator to ensure they're not legal characters in WP plugins (or themes).
Given my use case "--status=!inactive" would be the more useful, although I'm sure others would have use cases for multiple positive filters.
Unfortunately the whole reason I was using WP CLI in the first place was so as to avoid needing to develop in PHP. I'm unqualified to provide a patch for this.
--status=!inactive will be more difficult to parse and will not as easily be adapted for other flags/commands. Allowing for a set of multiple elements as a first iteration is much more straight-forward in terms of implementation.
Unfortunately the whole reason I was using WP CLI in the first place was so as to avoid needing to develop in PHP. I'm unqualified to provide a patch for this.
That's perfectly fine! We'll see whether other people might find inspiration here to provide a patch. Given the usefulness and applicability to other commands, I might even consider writing this one myself if I find the time.
@schlessera I have started having a look at it and found where WPCLI return all the status for a certain plugin but can't find where does it do the filtering for showing the final table at the formatter.
@xyulex You seem to be on the right track (from what I can see in the commits here), but you're removing the original logic in the process. This breaks everything but the status field.
You need to add to the existing logic, instead of replacing it.
The first commit broke everything, then I checked if the parameter was 'status'. I think that's corrected in ( #edcf08 ). At least, the commands work on it. I will keep checking it. Thanks for your feedback.
Activity
schlessera commentedon Aug 25, 2019
I think it makes sense to accept a comma-separated list here for multiple status values.
Would you be interested in providing a pull request for this, @Athanasius ?
Athanasius commentedon Aug 25, 2019
Given my use case "--status=!inactive" would be the more useful, although I'm sure others would have use cases for multiple positive filters.
Unfortunately the whole reason I was using WP CLI in the first place was so as to avoid needing to develop in PHP. I'm unqualified to provide a patch for this.
schlessera commentedon Aug 25, 2019
--status=!inactivewill be more difficult to parse and will not as easily be adapted for other flags/commands. Allowing for a set of multiple elements as a first iteration is much more straight-forward in terms of implementation.That's perfectly fine! We'll see whether other people might find inspiration here to provide a patch. Given the usefulness and applicability to other commands, I might even consider writing this one myself if I find the time.
xyulex commentedon Oct 23, 2019
@schlessera I would like to give it a go. It's the first issue I am trying to do, so be patient... :)
schlessera commentedon Oct 23, 2019
@xyulex Yes, no problem. Just let me know if you need assistance.
xyulex commentedon Oct 23, 2019
@schlessera I have started having a look at it and found where WPCLI return all the status for a certain plugin but can't find where does it do the filtering for showing the final table at the formatter.
schlessera commentedon Oct 23, 2019
The filtering should be happening here:
https://github.com/wp-cli/extension-command/blob/master/src/WP_CLI/CommandWithUpgrade.php#L488-L493
xyulex commentedon Oct 23, 2019
OK, thanks, I just found it.
Support multiple values on "plugin list --status=X" wp-cli#194
Support multiple values on "plugin list --status=X" wp-cli#194
Support multiple values on "plugin list --status=X" wp-cli#194
Support multiple values on "plugin list --status=X" wp-cli#194
schlessera commentedon Oct 24, 2019
@xyulex You seem to be on the right track (from what I can see in the commits here), but you're removing the original logic in the process. This breaks everything but the status field.
You need to add to the existing logic, instead of replacing it.
xyulex commentedon Oct 24, 2019
The first commit broke everything, then I checked if the parameter was 'status'. I think that's corrected in ( #edcf08 ). At least, the commands work on it. I will keep checking it. Thanks for your feedback.
zaantar commentedon Jun 4, 2020
I'll give it a try, if that's ok.
[wp-cli#194] Allow for filtering my a multiple field values for the "…
[wp-cli#194] Allow for filtering my a multiple field values for the "…
[wp-cli#194] Allow for filtering my a multiple field values for the "…
[wp-cli#194] Allow for filtering my a multiple field values for the "…
Merge pull request #234 from zaantar/wp-cli/194