Closed gemal closed 7 months ago
Thanks for your suggestion!
What would be your expected output for this case and what would it be useful for?
Maybe something like this?
$ wp core version --format=json
{ "version": "6.4.1" }
Yes that would be perfect!
While it probably wouldn't be difficult to get the same output with wp core version
+ jq
, I suppose we could add this.
Would you be interested in attempting to submit a pull request as part of today's WP-CLI Hack Day?
@gemal Out of curiosity, why is a string insufficient? I'm not a huge fan of adding --format=<format>
to wp core version
. It seems extraneous.
I just have a tool that scans through a lot of wordpress sites and extracts various information about them like plugins, themes, users and I needed to also show the version and all of the other commands supported returning json so I build my tool that way so I just found it strangely inconsistent that core version did not support this
Output of wp core version
is always a single value and it is obviously a version. So adding format option for the output with single value seems extraneous to me also.
jq
could be piped if formatted JSON value is needed.
Example:
wp core version | jq -R -c '{version:.}'
If I try to run
wp core version --format=json
I get: