From e8f1039c39b117bbb2cead089f346e01dcf4561f Mon Sep 17 00:00:00 2001 From: miya0001 Date: Fri, 20 May 2016 00:12:47 +0900 Subject: [PATCH 01/19] Example: core multisite-convert --- php/commands/core.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/php/commands/core.php b/php/commands/core.php index 4e23f1509e..b27ad6337b 100644 --- a/php/commands/core.php +++ b/php/commands/core.php @@ -472,6 +472,13 @@ public function install( $args, $assoc_args ) { * [--subdomains] * : If passed, the network will use subdomains, instead of subdirectories. Doesn't work with 'localhost'. * + * ## EXAMPLES + * + * $ wp core multisite-convert + * Set up multisite database tables. + * Added multisite constants to wp-config.php. + * Success: Network installed. Don't forget to set up rewrite rules. + * * @subcommand multisite-convert * @alias install-network */ From 4ad1b14c1e42290cc0cbd4e8136041de41bb74bd Mon Sep 17 00:00:00 2001 From: miya0001 Date: Fri, 20 May 2016 00:25:10 +0900 Subject: [PATCH 02/19] Example: core multisite-install --- php/commands/core.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/php/commands/core.php b/php/commands/core.php index 4e23f1509e..f0ddcb9d32 100644 --- a/php/commands/core.php +++ b/php/commands/core.php @@ -519,6 +519,16 @@ public function multisite_convert( $args, $assoc_args ) { * [--skip-email] * : Don't send an email notification to the new admin user. * + * ## EXAMPLES + * + * $ wp core multisite-install --title="Welcome to the WordPress" \ + * > --admin_user="admin" --admin_password="password" \ + * > --admin_email="user@example.com" + * Single site database tables already present. + * Set up multisite database tables. + * Added multisite constants to wp-config.php. + * Success: Network installed. Don't forget to set up rewrite rules. + * * @subcommand multisite-install */ public function multisite_install( $args, $assoc_args ) { From 818cbe49b8b3b58bbd8e2bfa657b12b87873a286 Mon Sep 17 00:00:00 2001 From: hideokamoto Date: Thu, 19 May 2016 15:53:17 +0000 Subject: [PATCH 03/19] Example: plugin list #2769 --- php/commands/plugin.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/php/commands/plugin.php b/php/commands/plugin.php index 734e2fec6e..a70003147c 100644 --- a/php/commands/plugin.php +++ b/php/commands/plugin.php @@ -639,10 +639,24 @@ function delete( $args, $assoc_args = array() ) { * * ## EXAMPLES * - * wp plugin list --status=active --format=json + * $ wp plugin list --status=active --format=json + * [{"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"}] * * # List plugins on each site in a network - * wp site list --field=url | xargs -n 1 -I % wp plugin list --url=% + * $ wp site list --field=url | xargs -n 1 -I % wp plugin list --url=% + * +------------------------------+----------------+-----------+------------+ + * | name | status | update | version | + * +------------------------------+----------------+-----------+------------+ + * | akismet | active-network | none | 3.1.11 | + * | hello | inactive | none | 1.6 | + * +------------------------------+----------------+-----------+------------+ + * +------------------------------+----------------+-----------+------------+ + * | name | status | update | version | + * +------------------------------+----------------+-----------+------------+ + * | akismet | active-network | none | 3.1.11 | + * | hello | inactive | none | 1.6 | + * +------------------------------+----------------+-----------+------------+ + * * * @subcommand list */ From 5b9954e7e10f1039b1e753daaa6c23656ada8845 Mon Sep 17 00:00:00 2001 From: hideokamoto Date: Thu, 19 May 2016 15:58:21 +0000 Subject: [PATCH 04/19] Example: plugin delete #2770 --- php/commands/plugin.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/php/commands/plugin.php b/php/commands/plugin.php index 734e2fec6e..32994bf613 100644 --- a/php/commands/plugin.php +++ b/php/commands/plugin.php @@ -590,10 +590,12 @@ function is_installed( $args, $assoc_args = array() ) { * * ## EXAMPLES * - * wp plugin delete hello + * $ wp plugin delete hello + * Success: Deleted 'hello' plugin. * * # Delete inactive plugins - * wp plugin delete $(wp plugin list --status=inactive --field=name) + * $ wp plugin delete $(wp plugin list --status=inactive --field=name) + * Success: Deleted 'tinymce-templates' plugin. */ function delete( $args, $assoc_args = array() ) { foreach ( $this->fetcher->get_many( $args ) as $plugin ) { From 58bbdb3972bd97344613d739edb7fc5704ab16cb Mon Sep 17 00:00:00 2001 From: hideokamoto Date: Thu, 19 May 2016 16:03:43 +0000 Subject: [PATCH 05/19] Example: plugin path #2770 --- php/commands/plugin.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/php/commands/plugin.php b/php/commands/plugin.php index 734e2fec6e..ed72dfca60 100644 --- a/php/commands/plugin.php +++ b/php/commands/plugin.php @@ -301,7 +301,8 @@ function toggle( $args, $assoc_args = array() ) { * * ## EXAMPLES * - * cd $(wp plugin path) + * $ cd $(wp plugin path) && pwd + * /var/www/wordpress/wp-content/plugins */ function path( $args, $assoc_args ) { $path = untrailingslashit( WP_PLUGIN_DIR ); From 9cab5f53042bfc2ebac86bd576050dc29f30f660 Mon Sep 17 00:00:00 2001 From: Shinichi Nishikawa Date: Fri, 20 May 2016 01:03:44 +0900 Subject: [PATCH 06/19] #2769 add example to cli update command document. --- php/commands/cli.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/php/commands/cli.php b/php/commands/cli.php index be6d1bd61b..d0b31dd411 100644 --- a/php/commands/cli.php +++ b/php/commands/cli.php @@ -135,6 +135,14 @@ public function check_update( $_, $assoc_args ) { * * [--yes] * : Do not prompt for confirmation + * + * ## EXAMPLES + * + * $ wp cli update + * You have version 0.23.0. Would you like to update to 0.23.1? [y/n] y + * Downloading from https://github.com/wp-cli/wp-cli/releases/download/v0.23.1/wp-cli-0.23.1.phar... + * New version works. Proceeding to replace. + * Success: Updated WP-CLI to 0.23.1 */ public function update( $_, $assoc_args ) { if ( ! Utils\inside_phar() ) { From 277eda42f7252543126ed627a00cca2cabef35f4 Mon Sep 17 00:00:00 2001 From: hideokamoto Date: Thu, 19 May 2016 16:14:14 +0000 Subject: [PATCH 07/19] Example: plugin update #2770 --- php/commands/plugin.php | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/php/commands/plugin.php b/php/commands/plugin.php index 734e2fec6e..e3d067a607 100644 --- a/php/commands/plugin.php +++ b/php/commands/plugin.php @@ -366,9 +366,34 @@ protected function install_from_repo( $slug, $assoc_args ) { * * ## EXAMPLES * - * wp plugin update bbpress --version=dev - * - * wp plugin update --all + * $ wp plugin update bbpress --version=dev + * Installing bbPress (Development Version) + * Downloading install package from https://downloads.wordpress.org/plugin/bbpress.zip... + * Unpacking the package... + * Installing the plugin... + * Removing the old version of the plugin... + * Plugin updated successfully. + * + * $ wp plugin update --all + * Enabling Maintenance mode... + * Downloading update from https://downloads.wordpress.org/plugin/akismet.3.1.11.zip... + * Unpacking the update... + * Installing the latest version... + * Removing the old version of the plugin... + * Plugin updated successfully. + * Downloading update from https://downloads.wordpress.org/plugin/nginx-champuru.3.2.0.zip... + * Unpacking the update... + * Installing the latest version... + * Removing the old version of the plugin... + * Plugin updated successfully. + * Disabling Maintenance mode... + * Success: Updated 2/2 plugins. + * +------------------------+-------------+-------------+---------+ + * | name | old_version | new_version | status | + * +------------------------+-------------+-------------+---------+ + * | akismet | 3.1.3 | 3.1.11 | Updated | + * | nginx-cache-controller | 3.1.1 | 3.2.0 | Updated | + * +------------------------+-------------+-------------+---------+ * * @alias upgrade */ From 3984f650372eb1808952ba115e6cb3936c8c23f0 Mon Sep 17 00:00:00 2001 From: hideokamoto Date: Thu, 19 May 2016 16:17:12 +0000 Subject: [PATCH 08/19] Example: plugin get #2770 --- php/commands/plugin.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/php/commands/plugin.php b/php/commands/plugin.php index 734e2fec6e..06b6502a9e 100644 --- a/php/commands/plugin.php +++ b/php/commands/plugin.php @@ -488,7 +488,8 @@ function install( $args, $assoc_args ) { * * ## EXAMPLES * - * wp plugin get bbpress --format=json + * $ wp plugin get bbpress --format=json + * {"name":"bbpress","title":"bbPress","author":"The bbPress Contributors","version":"2.6-alpha","description":"bbPress is forum software with a twist from the creators of WordPress.","status":"active"} */ public function get( $args, $assoc_args ) { $plugin = $this->fetcher->get_check( $args[0] ); From 99a08721d56e3df2232c54ce546861303b3c712a Mon Sep 17 00:00:00 2001 From: hideokamoto Date: Thu, 19 May 2016 16:20:16 +0000 Subject: [PATCH 09/19] Example: plugin uninstall #2770 --- php/commands/plugin.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/php/commands/plugin.php b/php/commands/plugin.php index 734e2fec6e..96f174106c 100644 --- a/php/commands/plugin.php +++ b/php/commands/plugin.php @@ -531,7 +531,8 @@ public function get( $args, $assoc_args ) { * * ## EXAMPLES * - * wp plugin uninstall hello + * $ wp plugin uninstall hello + * Success: Uninstalled and deleted 'hello' plugin. */ function uninstall( $args, $assoc_args = array() ) { foreach ( $this->fetcher->get_many( $args ) as $plugin ) { From 99e96cd9cc31f96a88b6cb7406733fdd570ec480 Mon Sep 17 00:00:00 2001 From: Shinichi Nishikawa Date: Fri, 20 May 2016 01:20:50 +0900 Subject: [PATCH 10/19] Example: cli version --- php/commands/cli.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/php/commands/cli.php b/php/commands/cli.php index be6d1bd61b..ee9407454e 100644 --- a/php/commands/cli.php +++ b/php/commands/cli.php @@ -43,6 +43,11 @@ public function version() { * * [--format=] * : Accepted values: json + * + * ## EXAMPLES + * + * $ wp cli version + * WP-CLI 0.23.1 */ public function info( $_, $assoc_args ) { $php_bin = WP_CLI::get_php_binary(); From f86d5b77553987874e78bdd1249f4d43cdd7f735 Mon Sep 17 00:00:00 2001 From: Shinichi Nishikawa Date: Fri, 20 May 2016 01:38:39 +0900 Subject: [PATCH 11/19] Example: option get --- php/commands/option.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/php/commands/option.php b/php/commands/option.php index 6fd5274295..787c1e8080 100644 --- a/php/commands/option.php +++ b/php/commands/option.php @@ -28,6 +28,14 @@ class Option_Command extends WP_CLI_Command { * * [--format=] * : Get value as var_export() or JSON. Default: var_export() + * + * ## EXAMPLES + * + * $ wp option get home + * http://example.com + * + * $ wp option get active_plugins --format=json + * {"0":"dynamically-dynamic-sidebar\/dynamically-dynamic-sidebar.php","1":"monster-widget\/monster-widget.php","2":"show-current-template\/show-current-template.php","3":"theme-check\/theme-check.php","5":"wordpress-importer\/wordpress-importer.php"} */ public function get( $args, $assoc_args ) { list( $key ) = $args; From 40379876ec591cadf0061473e0934af869a9a67f Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Thu, 19 May 2016 22:24:47 +0545 Subject: [PATCH 12/19] add example for transient delete-all command --- php/commands/transient.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/php/commands/transient.php b/php/commands/transient.php index 09d05eb1ce..78fad25930 100644 --- a/php/commands/transient.php +++ b/php/commands/transient.php @@ -133,6 +133,11 @@ public function delete_expired() { /** * Delete all transients. * + * ## EXAMPLES + * + * wp transient delete-all + * Success: 14 transients deleted from the database. + * * @subcommand delete-all */ public function delete_all() { From a8cc9be5941c5805963bafe1af826331b96f2ac3 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Thu, 19 May 2016 22:27:14 +0545 Subject: [PATCH 13/19] add missing dollar sign in command example --- php/commands/transient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/commands/transient.php b/php/commands/transient.php index 78fad25930..3fc77dba4d 100644 --- a/php/commands/transient.php +++ b/php/commands/transient.php @@ -135,7 +135,7 @@ public function delete_expired() { * * ## EXAMPLES * - * wp transient delete-all + * $ wp transient delete-all * Success: 14 transients deleted from the database. * * @subcommand delete-all From 8f6cfd8685ee4ebf85fea53a5c2ec666b46ec2aa Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Thu, 19 May 2016 22:29:33 +0545 Subject: [PATCH 14/19] Add example for transient delete-expired --- php/commands/transient.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/php/commands/transient.php b/php/commands/transient.php index 09d05eb1ce..31ab2bff92 100644 --- a/php/commands/transient.php +++ b/php/commands/transient.php @@ -104,6 +104,11 @@ public function type() { /** * Delete all expired transients. * + * ## EXAMPLES + * + * $ wp transient delete-expired + * Success: 12 expired transients deleted from the database. + * * @subcommand delete-expired */ public function delete_expired() { From 3388d39693b0a7969b9389e7b27a9208a74b6d40 Mon Sep 17 00:00:00 2001 From: hideokamoto Date: Thu, 19 May 2016 16:50:55 +0000 Subject: [PATCH 15/19] Example:plugin install #2770 --- php/commands/plugin.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/php/commands/plugin.php b/php/commands/plugin.php index 734e2fec6e..c55a5bec97 100644 --- a/php/commands/plugin.php +++ b/php/commands/plugin.php @@ -449,16 +449,36 @@ protected function filter_item_list( $items, $args ) { * ## EXAMPLES * * # Install the latest version from wordpress.org and activate - * wp plugin install bbpress --activate + * $ wp plugin install bbpress --activate + * Installing bbPress (2.5.9) + * Downloading install package from https://downloads.wordpress.org/plugin/bbpress.2.5.9.zip... + * Using cached file '/home/vagrant/.wp-cli/cache/plugin/bbpress-2.5.9.zip'... + * Unpacking the package... + * Installing the plugin... + * Plugin installed successfully. + * Activating 'bbpress'... + * Success: Plugin 'bbpress' activated. * * # Install the development version from wordpress.org - * wp plugin install bbpress --version=dev + * $ wp plugin install bbpress --version=dev + * Installing bbPress (Development Version) + * Downloading install package from https://downloads.wordpress.org/plugin/bbpress.zip... + * Unpacking the package... + * Installing the plugin... + * Plugin installed successfully. * * # Install from a local zip file - * wp plugin install ../my-plugin.zip + * $ wp plugin install ../my-plugin.zip + * Unpacking the package... + * Installing the plugin... + * Plugin installed successfully. * * # Install from a remote zip file - * wp plugin install http://s3.amazonaws.com/bucketname/my-plugin.zip?AWSAccessKeyId=123&Expires=456&Signature=abcdef + * $ wp plugin install http://s3.amazonaws.com/bucketname/my-plugin.zip?AWSAccessKeyId=123&Expires=456&Signature=abcdef + * Downloading install package from http://s3.amazonaws.com/bucketname/my-plugin.zip?AWSAccessKeyId=123&Expires=456&Signature=abcdef + * Unpacking the package... + * Installing the plugin... + * Plugin installed successfully. */ function install( $args, $assoc_args ) { From f89a55bb27415ac88efa373050bf8468a489eb5a Mon Sep 17 00:00:00 2001 From: Shinichi Nishikawa Date: Fri, 20 May 2016 01:55:13 +0900 Subject: [PATCH 16/19] Example: taxonomy get --- php/commands/taxonomy.php | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/php/commands/taxonomy.php b/php/commands/taxonomy.php index addfb8c324..3579ebbf69 100644 --- a/php/commands/taxonomy.php +++ b/php/commands/taxonomy.php @@ -99,7 +99,38 @@ public function list_( $args, $assoc_args ) { * * ## EXAMPLES * - * wp taxonomy get post_tag --format=json + * $ wp taxonomy get category + * +---------------+---------------------------------------------------+ + * | Field | Value | + * +---------------+---------------------------------------------------+ + * | name | category | + * | label | Categories | + * | description | | + * | object_type | ["post"] | + * | show_tagcloud | true | + * | hierarchical | true | + * | public | true | + * | labels | {"name":"Categories","singular_name":"Category"," | + * | | search_items":"Search Categories","popular_items" | + * | | :null,"all_items":"All Categories","parent_item": | + * | | "Parent Category","parent_item_colon":"Parent Cat | + * | | egory:","edit_item":"Edit Category","view_item":" | + * | | View Category","update_item":"Update Category","a | + * | | dd_new_item":"Add New Category","new_item_name":" | + * | | New Category Name","separate_items_with_commas":n | + * | | ull,"add_or_remove_items":null,"choose_from_most_ | + * | | used":null,"not_found":"No categories found.","no | + * | | _terms":"No categories","items_list_navigation":" | + * | | Categories list navigation","items_list":"Categor | + * | | ies list","menu_name":"Categories","name_admin_ba | + * | | r":"category"} | + * | cap | {"manage_terms":"manage_categories","edit_terms": | + * | | "manage_categories","delete_terms":"manage_catego | + * | | ries","assign_terms":"edit_posts"} | + * +---------------+---------------------------------------------------+ + * + * $ wp taxonomy get post_tag --field=cap + * {"manage_terms":"manage_categories","edit_terms":"manage_categories","delete_terms":"manage_categories","assign_terms":"edit_posts"} */ public function get( $args, $assoc_args ) { $taxonomy = get_taxonomy( $args[0] ); From a30d40fba4df4f8fe17e75919df7b19e828dac89 Mon Sep 17 00:00:00 2001 From: ernilambar Date: Fri, 20 May 2016 14:45:10 +0545 Subject: [PATCH 17/19] bail early in theme command if theme is broken or has error --- php/commands/theme.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/php/commands/theme.php b/php/commands/theme.php index 980967d7e1..45ca6ea005 100644 --- a/php/commands/theme.php +++ b/php/commands/theme.php @@ -127,6 +127,12 @@ protected function get_status( $theme ) { public function activate( $args = array() ) { $theme = $this->fetcher->get_check( $args[0] ); + $errors = $theme->errors(); + if ( is_wp_error( $errors ) ) { + $message = $errors->get_error_message(); + WP_CLI::error( $message ); + } + $name = $theme->get('Name'); if ( 'active' === $this->get_status( $theme ) ) { @@ -420,6 +426,12 @@ function install( $args, $assoc_args ) { public function get( $args, $assoc_args ) { $theme = $this->fetcher->get_check( $args[0] ); + $errors = $theme->errors(); + if ( is_wp_error( $errors ) ) { + $message = $errors->get_error_message(); + WP_CLI::error( $message ); + } + // WP_Theme object employs magic getter, unfortunately $theme_vars = array( 'name', 'title', 'version', 'parent_theme', 'template_dir', 'stylesheet_dir', 'template', 'stylesheet', 'screenshot', 'description', 'author', 'tags', 'theme_root', 'theme_root_uri', ); From 2941fbe5fb94d09164f99a4dce43851a48d61805 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Sat, 21 May 2016 22:01:41 +0545 Subject: [PATCH 18/19] fix error message in theme activate scenario as message for broken theme is changed --- features/theme.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/theme.feature b/features/theme.feature index 505062fc2a..f6e2cb14ce 100644 --- a/features/theme.feature +++ b/features/theme.feature @@ -236,7 +236,7 @@ Feature: Manage WordPress themes When I try `wp theme activate biker` Then STDERR should contain: """ - Error: The 'biker' theme cannot be activated without its parent, 'jolene'. + Error: The parent theme is missing. Please install the "jolene" parent theme. """ Scenario: List an active theme with its parent From ac00c9783e2424ecdf06f7b830c5bb542a31b9c9 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Sat, 21 May 2016 22:11:02 +0545 Subject: [PATCH 19/19] add scenario for add error message in theme get and theme activate --- features/theme.feature | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/features/theme.feature b/features/theme.feature index f6e2cb14ce..6704bf24a0 100644 --- a/features/theme.feature +++ b/features/theme.feature @@ -129,6 +129,22 @@ Feature: Manage WordPress themes | name | status | | p2 | active | + Scenario: Attempt to activate or fetch a broken theme + Given a WP install + And I run `mkdir -pv wp-content/themes/just-test-theme` + + When I try `wp theme activate just-test-theme` + Then STDERR should contain: + """ + Error: Stylesheet is missing. + """ + + When I try `wp theme get just-test-theme` + Then STDERR should contain: + """ + Error: Stylesheet is missing. + """ + Scenario: Enabling and disabling a theme Given a WP multisite install And I run `wp theme install jolene`