wp-cli / core-command

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

[ wp core check-update ] - format options parameter #250

Closed riccardodicurti closed 8 months ago

riccardodicurti commented 9 months ago

Summary: From the information contained in the WordPress Developer Resources I read that it can set the return format https://developer.wordpress.org/cli/commands/core/update/ but give a return only for table format.

Steps to reproduce: Run command ‘wp core check-update --format=json’

` /**

danielbachhuber commented 9 months ago

Thanks for the report, @riccardodicurti

I believe wp core check-update --format=json returns an empty result because there are no updates available.

What is your expected behavior?

riccardodicurti commented 9 months ago

Ciao @danielbachhuber I would at least expect an empty json or a message telling me that no updates are available.

danielbachhuber commented 9 months ago

I would at least expect an empty json or a message telling me that no updates are available.

I'm not sure a message would make sense. If you're passing the data into JSON parser, a string would break the parser.

wp post list --format=json produces an empty array:

$ wp post list --format=json
[]

Would an empty array work for your purposes?

Also, for posterity, could you share a bit more detail about your use case?

riccardodicurti commented 9 months ago

Yes, my suggestion was definitely to return the message via json. In any case, the empty array is still sufficient to verify that we have received the response.

I am currently writing a set of tests and update routines via ssh using the cli.

danielbachhuber commented 9 months ago

Ok, makes sense. I think I'd be fine to change wp core check-update --format=json to return an empty array, and consider this a bug in the original implementation.