Skip to content

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

Description

@riccardodicurti

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’

` /**
* Checks for WordPress updates via Version Check API.
*
* Lists the most recent versions when there are updates available,
* or success message when up to date.
*
* ## OPTIONS
*
* [--minor]
* : Compare only the first two parts of the version number.
*
* [--major]
* : Compare only the first part of the version number.
*
* [--force-check]
* : Bypass the transient cache and force a fresh update check.
*
* [--field=]
* : Prints the value of a single field for each update.
*
* [--fields=]
* : Limit the output to specific object fields. Defaults to version,update_type,package_url.
*
* [--format=]
* : Render output in a particular format.
* ---
* default: table
* options:
* - table
* - csv
* - count
* - json
* - yaml
* ---
*
* ## EXAMPLES
*
* $ wp core check-update
* +---------+-------------+-------------------------------------------------------------+
* | version | update_type | package_url |
* +---------+-------------+-------------------------------------------------------------+
* | 4.5.2 | major | https://downloads.wordpress.org/release/wordpress-4.5.2.zip |
* +---------+-------------+-------------------------------------------------------------+
*
* @subcommand check-update
*/
public function check_update( $_, $assoc_args ) {

	$updates = $this->get_updates( $assoc_args );
	if ( $updates ) {
		$updates   = array_reverse( $updates );
		$formatter = new Formatter(
			$assoc_args,
			[ 'version', 'update_type', 'package_url' ]
		);
		$formatter->display_items( $updates );
	} elseif ( empty( $assoc_args['format'] ) || 'table' === $assoc_args['format'] ) {
		WP_CLI::success( 'WordPress is at the latest version.' );
	}
}

`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions