Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e8f1039
Example: core multisite-convert
miya0001 May 19, 2016
4ad1b14
Example: core multisite-install
miya0001 May 19, 2016
818cbe4
Example: plugin list
hideokamoto May 19, 2016
5b9954e
Example: plugin delete #2770
hideokamoto May 19, 2016
58bbdb3
Example: plugin path #2770
hideokamoto May 19, 2016
9cab5f5
#2769 add example to cli update command document.
ShinichiNishikawa May 19, 2016
277eda4
Example: plugin update #2770
hideokamoto May 19, 2016
3984f65
Example: plugin get #2770
hideokamoto May 19, 2016
99a0872
Example: plugin uninstall #2770
hideokamoto May 19, 2016
99e96cd
Example: cli version
ShinichiNishikawa May 19, 2016
f86d5b7
Example: option get
ShinichiNishikawa May 19, 2016
4037987
add example for transient delete-all command
ernilambar May 19, 2016
a8cc9be
add missing dollar sign in command example
ernilambar May 19, 2016
8f6cfd8
Add example for transient delete-expired
ernilambar May 19, 2016
3388d39
Example:plugin install #2770
hideokamoto May 19, 2016
f89a55b
Example: taxonomy get
ShinichiNishikawa May 19, 2016
a30d40f
bail early in theme command if theme is broken or has error
ernilambar May 20, 2016
7c2f2e9
Merge pull request #2785 from ShinichiNishikawa/audit-cli-update
danielbachhuber May 20, 2016
503a7f4
Merge pull request #2784 from hideokamoto/example-plugin-path
danielbachhuber May 20, 2016
d698c66
Merge pull request #2783 from hideokamoto/example-plugin-delete
danielbachhuber May 20, 2016
e49db2c
Merge pull request #2789 from ShinichiNishikawa/audit-cli-version
danielbachhuber May 20, 2016
d610d60
Merge pull request #2797 from ShinichiNishikawa/audit-taxonomy-get
danielbachhuber May 20, 2016
456b70c
Merge pull request #2792 from ShinichiNishikawa/audit-option-get
danielbachhuber May 20, 2016
a9b4395
Merge pull request #2782 from hideokamoto/example-plugin-list
danielbachhuber May 20, 2016
8ff08b0
Merge pull request #2788 from hideokamoto/example-plugin-uninstall
danielbachhuber May 20, 2016
297ae0d
Merge pull request #2796 from hideokamoto/example-plugin-install
danielbachhuber May 20, 2016
f5027d8
Merge pull request #2787 from hideokamoto/example-plugin-get
danielbachhuber May 20, 2016
d78e9f6
Merge pull request #2786 from hideokamoto/example-plugin-update
danielbachhuber May 20, 2016
e414207
Merge pull request #2781 from miya0001/example-core-multisite-convert
danielbachhuber May 20, 2016
276eea3
Merge pull request #2780 from miya0001/example-core-multisite-install
danielbachhuber May 20, 2016
6cfb127
Merge pull request #2793 from ernilambar/example-transient-delete-all
danielbachhuber May 20, 2016
3e412ac
Merge pull request #2795 from ernilambar/example-transient-delete-exp…
danielbachhuber May 20, 2016
419ae34
Merge branch 'branch-2790' of github.com:ernilambar/wp-cli into branc…
ernilambar May 20, 2016
2941fbe
fix error message in theme activate scenario as message for broken th…
ernilambar May 21, 2016
ac00c97
add scenario for add error message in theme get and theme activate
ernilambar May 21, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion features/theme.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -236,7 +252,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
Expand Down
13 changes: 13 additions & 0 deletions php/commands/cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public function version() {
*
* [--format=<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();
Expand Down Expand Up @@ -135,6 +140,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() ) {
Expand Down
17 changes: 17 additions & 0 deletions php/commands/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -519,6 +526,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 ) {
Expand Down
8 changes: 8 additions & 0 deletions php/commands/option.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ class Option_Command extends WP_CLI_Command {
*
* [--format=<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;
Expand Down
92 changes: 78 additions & 14 deletions php/commands/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -366,9 +367,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
*/
Expand Down Expand Up @@ -449,16 +475,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 ) {

Expand Down Expand Up @@ -488,7 +534,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] );
Expand Down Expand Up @@ -531,7 +578,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 ) {
Expand Down Expand Up @@ -590,10 +638,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 ) {
Expand Down Expand Up @@ -639,10 +689,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
*/
Expand Down
33 changes: 32 additions & 1 deletion php/commands/taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] );
Expand Down
12 changes: 12 additions & 0 deletions php/commands/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down Expand Up @@ -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',
);
Expand Down
10 changes: 10 additions & 0 deletions php/commands/transient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -133,6 +138,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() {
Expand Down