WP-CLI The command line interface for WordPress

Version 0.8

by scribu, on 26 Jan 2013

Version 0.8.0 is now available.

Changelog

Commands:

  • added wp search-replace. hat tip to interconnectit/Search-Replace-DB
  • added wp scaffold
  • added wp cap
  • added wp user add-role
  • added --role parameter to wp user remove-role
  • added --ids parameter to wp user list
  • added --post__in parameter to wp export
  • added --str parameter to most wp db subcommands
  • removed community commands (wp total-cache, wp super-cache, wp sitemap)
  • made wp post update accept multiple IDs
  • fixed incorrect exit code from wp core is-installed in some cases
  • fixed wp user import-csv
  • fixed wp theme update <theme>
  • fixed wp plugin update <plugin> not reactivating the plugin

Internals:

  • added support for wp-cli.yml config file
  • bypass full-page caching plugins
  • disabled coloring when not in a TTY and added --color/no-color global parameters
  • added --debug global parameter
  • added wp --info utility
  • added unit tests for wp core subcommands
  • Composer compatibility

You can also browse the full list of resolved issues.

Contributors to this release: danielbachhuber, ericmann, jmslbam, milesj, mwilliamson, scribu, sebastiaandegeus.

Version 0.7

by scribu, on 16 Nov 2012

Version 0.7.0 is now available.

If you had installed WP-CLI using PEAR, you will probably have to re-install it from scratch, since the URL for the channel has changed.

There is a new wiki page for creating commands which has information about the new @synopsis tag etc. It also describes how you can create man pages for your custom commands.

Changelog

Commands:

  • added wp shell
  • added wp cache
  • added wp comment
  • added wp rewrite
  • added wp user import-csv
  • added wp user set-role and wp user remove-role
  • added wp core is-installed
  • added wp blog delete
  • added wp post list
  • made wp post delete accept a list of IDs
  • added --dry-run option wp plugin update-all
  • improved wp export

Breaking changes:

  • converted wp plugin update --all to wp plugin update-all
  • converted wp theme update --all to wp theme update-all
  • converted wp generate posts to wp post generate
  • converted wp generate users to wp user generate
  • renamed wp core install_network to wp core install-network
  • renamed --path option to --dir in wp export

Internals:

  • removed support for default subcommands
  • introduced @synopsis docblock tag
  • introduced @subcommand docblock tag
  • introduced @alias docblock tag
  • introduced WP_CLI::add_man_dir()

You can also browse the full list of resolved issues.

Contributors to this release: andreascreten, bendoh, builtbylane, danielbachhuber, goldenapples, jghazally, lackingpenguin, navitronic, ozh, scribu, tddewey.

Interactive WordPress Debugging

by scribu, on 10 Nov 2012

A new command landed in WP-CLI a few days ago, called shell. It was inspired by an older project called wpshell.

When you run wp shell, a REPL will start, in which you can run any WordPress function.

The major advantage over wp eval and wp eval-file is that it’s interactive: you immediately see the result of the previous command; it’s also stored in the special $_ variable, which you can use in the next command and so on.

Here’s a contrived example session:

scribu@air:~/wp/core$ wp shell
Type "exit" to close session.
wp> get_bloginfo('wpurl')
'http://wp.dev/core'
wp> $_ . '/feed/'
'http://wp.dev/core/feed/'
wp> exit
scribu@air:~/wp/core$

wp shell will be available in the 0.7 release of WP-CLI, but if you want to try it out right now, clone the latest version from GitHub. If you have suggestions for making it better, don’t hesitate to open issues and pull requests.

Version 0.6

by scribu, on 05 Sep 2012

Got a lot of exciting news regarding wp-cli, so let’s get right into it:

The Reach

Besides Dreamhost, it’s used and recommended by the WordPress.com VIP team to all their clients.

Oh, and it’s also used in a Juju Charm for deploying WordPress in the cloud. :D

The --require

An interesting but easily overlooked feature is the new --require global parameter. Say you wrote a custom command called chores for yourself:

WP_CLI::add_command( 'chores', 'My_Chores' );

class My_Chores extends WP_CLI_Command {

	function do_laundry() {
		...
	}
	
	function wash_dishes() {
		...
	}
}

Now, where do you put this code, so that WP-CLI can reach it? You could put it in a plugin, but if you have multiple WP installations, you’d have to install that plugin on each one. You could put it inside one of the WP-CLI directories, but that creates problems when you want to update. Here’s what you could do instead:

wp --require=/path/to/chores.php chores do_laundry

The --require parameter will load that PHP file at just the right time for the command to work as you’d expect.

The Manual

The help system has been improved. When you do wp help core config, an actual man page will show up, with details about each parameter:

wp-cli man-page

Unfortunately, this doesn’t work if you install WP-CLI via the PEAR package, because PEAR doesn’t know how to handle them. :(

The Changelog

Commands:

  • added wp post and wp post-meta
  • added wp user-meta
  • added wp blog create
  • added wp export
  • added wp theme install and wp theme update
  • added wp transient
  • added wp db optimize and wp db repair
  • added wp db create, wp db drop and wp db reset
  • added wp db import
  • added wp core install_network
  • added wp core update_db
  • added --json option to several subcommands
  • added --network option to wp plugin activate
  • fixed wp plugin update

Internals:

  • fixed “out of memory” error
  • misc bugfixes and optimizations

You can also browse the full list of resolved issues.

The Community

Most of the new commands you see in this release were actually implemented by other people.

Here are all the people that have contributed to this release: andreascreten, dwightjack, getsource, johnpbloch, joshstoik1, kidfiction, marcoceppi, mgburns, mwilliamson, roelven, scribu, soulou, tollmanz.

The Future

The first thing I want to tackle next is revamping the install process. I’m also thinking of ditching PEAR entirely; it’s just too limited: no man pages, no command auto-complete etc.

Beyond that, there are a lot of gaps to fill: wp import, wp blog update, wp attachment anyone?

Version 0.4

by scribu, on 29 Dec 2011

Version 0.4.0 is now available. See resolved issues.

Changelog

  • added wp eval and wp eval-file
  • added wp export
  • added wp core install
  • fixed wp core update
  • added --dev flag to wp plugin install
  • added wp plugin uninstall
  • fixed wp plugin install and wp plugin update

Contributors to this release: mwilliamson, scribu, tott.

Version 0.3

by scribu, on 06 Nov 2011

Version 0.3.0 is now available.

Changelog

Commands:

  • added wp sql
  • improved wp option
  • improved wp plugin and wp theme
  • added wp generate
  • added wp core version

Internals:

  • added --version special parameter
  • added --blog global parameter
  • added bash completion script
  • added pear installer

Contributors to this release: andreascreten, conatus, matiskay, nb, scribu, toszcze.