Skip to content

Commit d57c270

Browse files
authored
Merge pull request #380 from sejas/add/update-version-default-field
2 parents 0ddd27f + e12aac3 commit d57c270

File tree

7 files changed

+53
-36
lines changed

7 files changed

+53
-36
lines changed

features/plugin-update.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Feature: Update WordPress plugins
1313

1414
When I run `wp plugin list`
1515
Then STDOUT should be a table containing rows:
16-
| name | status | update | version | auto_update |
17-
| wordpress-importer | inactive | available | 0.5 | off |
16+
| name | status | update | version | update_version | auto_update |
17+
| wordpress-importer | inactive | available | 0.5 | {UPDATE_VERSION} | off |
1818

1919
When I try `wp plugin update akismet --version=0.5.3`
2020
Then STDERR should be:
@@ -25,16 +25,16 @@ Feature: Update WordPress plugins
2525

2626
When I run `wp plugin list`
2727
Then STDOUT should be a table containing rows:
28-
| name | status | update | version | auto_update |
29-
| wordpress-importer | inactive | available | 0.5 | off |
28+
| name | status | update | version | update_version | auto_update |
29+
| wordpress-importer | inactive | available | 0.5 | {UPDATE_VERSION} | off |
3030

3131
When I run `wp plugin update wordpress-importer`
3232
Then STDOUT should not be empty
3333

3434
When I run `wp plugin list`
3535
Then STDOUT should be a table containing rows:
36-
| name | status | update | version | auto_update |
37-
| wordpress-importer | inactive | none | {UPDATE_VERSION} | off |
36+
| name | status | update | version | update_version | auto_update |
37+
| wordpress-importer | inactive | none | {UPDATE_VERSION} | | off |
3838

3939
Scenario: Error when both --minor and --patch are provided
4040
Given a WP install

features/plugin.feature

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ Feature: Manage WordPress plugins
6363

6464
When I run `wp plugin list`
6565
Then STDOUT should be a table containing rows:
66-
| name | status | update | version | auto_update |
67-
| Zombieland | active | none | 0.1.0 | off |
66+
| name | status | update | version | update_version | auto_update |
67+
| Zombieland | active | none | 0.1.0 | | off |
6868

6969
When I try `wp plugin uninstall Zombieland`
7070
Then STDERR should be:
@@ -131,8 +131,8 @@ Feature: Manage WordPress plugins
131131

132132
When I run `wp plugin list`
133133
Then STDOUT should be a table containing rows:
134-
| name | status | update | version | auto_update |
135-
| wordpress-importer | active | available | 0.5 | off |
134+
| name | status | update | version | update_version | auto_update |
135+
| wordpress-importer | active | available | 0.5 | {UPDATE_VERSION} | off |
136136

137137
When I try `wp plugin update`
138138
Then STDERR should be:
@@ -650,11 +650,14 @@ Feature: Manage WordPress plugins
650650

651651
When I run `wp plugin list --name=hello-dolly --field=version`
652652
And save STDOUT as {PLUGIN_VERSION}
653+
654+
When I run `wp plugin list --name=hello-dolly --field=update_version`
655+
And save STDOUT as {UPDATE_VERSION}
653656

654657
When I run `wp plugin list`
655658
Then STDOUT should be a table containing rows:
656-
| name | status | update | version | auto_update |
657-
| hello-dolly | inactive | version higher than expected | {PLUGIN_VERSION} | off |
659+
| name | status | update | version | update_version | auto_update |
660+
| hello-dolly | inactive | version higher than expected | {PLUGIN_VERSION} | {UPDATE_VERSION} | off |
658661

659662
When I try `wp plugin update --all`
660663
Then STDERR should be:

features/theme.feature

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,14 @@ Feature: Manage WordPress themes
7777
When I run `wp theme install p2 --version=1.4.2`
7878
Then STDOUT should not be empty
7979

80+
When I run `wp theme list --name=p2 --field=update_version`
81+
Then STDOUT should not be empty
82+
And save STDOUT as {UPDATE_VERSION}
83+
8084
When I run `wp theme list`
8185
Then STDOUT should be a table containing rows:
82-
| name | status | update | version | auto_update |
83-
| p2 | inactive | available | 1.4.2 | off |
86+
| name | status | update | version | update_version | auto_update |
87+
| p2 | inactive | available | 1.4.2 | {UPDATE_VERSION} | off |
8488

8589
When I run `wp theme activate p2`
8690
Then STDOUT should not be empty
@@ -97,8 +101,8 @@ Feature: Manage WordPress themes
97101

98102
When I run `wp theme list`
99103
Then STDOUT should be a table containing rows:
100-
| name | status | update | version | auto_update |
101-
| p2 | active | available | 1.4.1 | off |
104+
| name | status | update | version | update_version | auto_update |
105+
| p2 | active | available | 1.4.1 | {UPDATE_VERSION} | off |
102106

103107
When I try `wp theme update`
104108
Then STDERR should be:

features/upgradables.feature

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ Feature: Manage WordPress themes and plugins
5151
"<item_title>"
5252
"""
5353

54+
When I run `wp <type> list --name=<item> --field=update_version`
55+
Then STDOUT should not be empty
56+
And save STDOUT as {UPDATE_VERSION}
57+
5458
When I run `wp <type> list`
5559
Then STDOUT should be a table containing rows:
56-
| name | status | update | version | auto_update |
57-
| <item> | inactive | available | <version> | off |
60+
| name | status | update | version | update_version | auto_update |
61+
| <item> | inactive | available | <version> | {UPDATE_VERSION} | off |
5862

5963
When I run `wp <type> list --field=name`
6064
Then STDOUT should contain:

src/Plugin_Command.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
5252
'status',
5353
'update',
5454
'version',
55+
'update_version',
5556
'auto_update',
5657
);
5758

@@ -1176,10 +1177,10 @@ public function delete( $args, $assoc_args = array() ) {
11761177
* * status
11771178
* * update
11781179
* * version
1180+
* * update_version
11791181
*
11801182
* These fields are optionally available:
11811183
*
1182-
* * update_version
11831184
* * update_package
11841185
* * update_id
11851186
* * title
@@ -1192,22 +1193,22 @@ public function delete( $args, $assoc_args = array() ) {
11921193
*
11931194
* # List active plugins on the site.
11941195
* $ wp plugin list --status=active --format=json
1195-
* [{"name":"dynamic-hostname","status":"active","update":"none","version":"0.4.2"},{"name":"tinymce-templates","status":"active","update":"none","version":"4.4.3"},{"name":"wp-multibyte-patch","status":"active","update":"none","version":"2.4"},{"name":"wp-total-hacks","status":"active","update":"none","version":"2.0.1"}]
1196+
* [{"name":"dynamic-hostname","status":"active","update":"none","version":"0.4.2","update_version": ""},{"name":"tinymce-templates","status":"active","update":"none","version":"4.4.3","update_version": ""},{"name":"wp-multibyte-patch","status":"active","update":"none","version":"2.4","update_version": ""},{"name":"wp-total-hacks","status":"active","update":"none","version":"2.0.1","update_version": ""}]
11961197
*
11971198
* # List plugins on each site in a network.
11981199
* $ wp site list --field=url | xargs -I % wp plugin list --url=%
1199-
* +---------+----------------+--------+---------+
1200-
* | name | status | update | version |
1201-
* +---------+----------------+--------+---------+
1202-
* | akismet | active-network | none | 3.1.11 |
1203-
* | hello | inactive | none | 1.6 |
1204-
* +---------+----------------+--------+---------+
1205-
* +---------+----------------+--------+---------+
1206-
* | name | status | update | version |
1207-
* +---------+----------------+--------+---------+
1208-
* | akismet | active-network | none | 3.1.11 |
1209-
* | hello | inactive | none | 1.6 |
1210-
* +---------+----------------+--------+---------+
1200+
* +---------+----------------+--------+---------+----------------+
1201+
* | name | status | update | version | update_version |
1202+
* +---------+----------------+--------+---------+----------------+
1203+
* | akismet | active-network | none | 3.1.11 | |
1204+
* | hello | inactive | none | 1.6 | 1.7.2 |
1205+
* +---------+----------------+--------+---------+----------------+
1206+
* +---------+----------------+--------+---------+----------------+
1207+
* | name | status | update | version | update_version |
1208+
* +---------+----------------+--------+---------+----------------+
1209+
* | akismet | active-network | none | 3.1.11 | |
1210+
* | hello | inactive | none | 1.6 | 1.7.2 |
1211+
* +---------+----------------+--------+---------+----------------+
12111212
*
12121213
* @subcommand list
12131214
*/

src/Theme_Command.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class Theme_Command extends CommandWithUpgrade {
5454
'status',
5555
'update',
5656
'version',
57+
'update_version',
5758
'auto_update',
5859
];
5960

@@ -852,10 +853,10 @@ public function delete( $args, $assoc_args ) {
852853
* * status
853854
* * update
854855
* * version
856+
* * update_version
855857
*
856858
* These fields are optionally available:
857859
*
858-
* * update_version
859860
* * update_package
860861
* * update_id
861862
* * title
@@ -866,9 +867,9 @@ public function delete( $args, $assoc_args ) {
866867
*
867868
* # List themes
868869
* $ wp theme list --status=inactive --format=csv
869-
* name,status,update,version
870-
* twentyfourteen,inactive,none,1.7
871-
* twentysixteen,inactive,available,1.1
870+
* name,status,update,version,update_version
871+
* twentyfourteen,inactive,none,1.7,
872+
* twentysixteen,inactive,available,1.1,
872873
*
873874
* @subcommand list
874875
*/

src/WP_CLI/CommandWithUpgrade.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,10 @@ protected function _list( $_, $assoc_args ) {
511511
$item['version'] = '';
512512
}
513513

514+
if ( empty( $item['update_version'] ) ) {
515+
$item['update_version'] = '';
516+
}
517+
514518
foreach ( $item as $field => &$value ) {
515519
if ( 'update' === $field ) {
516520
if ( true === $value ) {

0 commit comments

Comments
 (0)