|
5 | 5 | use WP_CLI\Iterators\Table as TableIterator;
|
6 | 6 | use WP_CLI\Utils;
|
7 | 7 | use WP_CLI\Formatter;
|
| 8 | +use WP_CLI\Loggers; |
8 | 9 | use WP_CLI\WpOrgApi;
|
9 | 10 |
|
10 | 11 | /**
|
@@ -1064,6 +1065,15 @@ private static function get_core_checksums( $version, $locale, $insecure ) {
|
1064 | 1065 | * [--locale=<locale>]
|
1065 | 1066 | * : Select which language you want to download.
|
1066 | 1067 | *
|
| 1068 | + * [--format=<format>] |
| 1069 | + * : Render output in a particular format. |
| 1070 | + * --- |
| 1071 | + * options: |
| 1072 | + * - table |
| 1073 | + * - csv |
| 1074 | + * - json |
| 1075 | + * --- |
| 1076 | + * |
1067 | 1077 | * [--insecure]
|
1068 | 1078 | * : Retry download without certificate validation if TLS handshake fails. Note: This makes the request vulnerable to a MITM attack.
|
1069 | 1079 | *
|
@@ -1109,6 +1119,11 @@ public function update( $args, $assoc_args ) {
|
1109 | 1119 | $assoc_args['version'] = 'nightly';
|
1110 | 1120 | }
|
1111 | 1121 |
|
| 1122 | + if ( ! empty( $assoc_args['format'] ) && in_array( $assoc_args['format'], [ 'json', 'csv' ], true ) ) { |
| 1123 | + $logger = new Loggers\Quiet( WP_CLI::get_runner()->in_color() ); |
| 1124 | + WP_CLI::set_logger( $logger ); |
| 1125 | + } |
| 1126 | + |
1112 | 1127 | if ( ! empty( $args[0] ) ) {
|
1113 | 1128 |
|
1114 | 1129 | // ZIP path or URL is given
|
@@ -1214,6 +1229,21 @@ public function update( $args, $assoc_args ) {
|
1214 | 1229 | $locale = (string) Utils\get_flag_value( $assoc_args, 'locale', get_locale() );
|
1215 | 1230 | $this->cleanup_extra_files( $from_version, $to_version, $locale, $insecure );
|
1216 | 1231 |
|
| 1232 | + $data = [ |
| 1233 | + [ |
| 1234 | + 'name' => 'core', |
| 1235 | + 'old_version' => $from_version, |
| 1236 | + 'new_version' => $to_version, |
| 1237 | + 'status' => 'Updated', |
| 1238 | + ], |
| 1239 | + ]; |
| 1240 | + |
| 1241 | + $format = Utils\get_flag_value( $assoc_args, 'format' ); |
| 1242 | + |
| 1243 | + if ( ! empty( $format ) ) { |
| 1244 | + Utils\format_items( $format, $data, [ 'name', 'old_version', 'new_version', 'status' ] ); |
| 1245 | + } |
| 1246 | + |
1217 | 1247 | WP_CLI::success( 'WordPress updated successfully.' );
|
1218 | 1248 | }
|
1219 | 1249 | } else {
|
|
0 commit comments