wp-cli / core-command

Downloads, installs, updates, and manages a WordPress installation.
MIT License
49 stars 50 forks source link

Format --format in core version #245

Closed gemal closed 7 months ago

gemal commented 1 year ago

If I try to run wp core version --format=json I get:

Error: Parameter errors:
 unknown --format parameter
swissspidy commented 1 year 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" }
gemal commented 1 year ago

Yes that would be perfect!

swissspidy commented 1 year ago

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?

danielbachhuber commented 1 year ago

@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.

gemal commented 1 year ago

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

ernilambar commented 7 months ago

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:.}'