What's new in Drush 4
The Drush project has been on fire in the past year. In January, we released Drush 4. I realize that we never properly introduced it. So, here are the highlights ...
Much more documentation
Like most unix commands, Drush has always had pretty strong command specific help. Just append --help to any command and you learn much of what it can do. In Drush 4, we added 14 topics and examples which are long-form help that's usually not related to a single command. For example, we discuss site aliases and the Drush bootstrap. The new command
topic is your tool for reading these docs. Topics are just text files, and modules/commandfiles can easily ship with them.
Adrian Rollett (acrollet) contributed 9 handy commands for managing user accounts on your Drupal site. Dealing with spammers or setting up new staff has never been quicker:
- user-add-role. Add a role to the specified user accounts.
- user-block. Block the specified user(s).
- user-cancel. Cancel a user account with the specified name.
- user-create. Create a user account with the specified name.
- user-information. Print information about the specified user(s).
- user-login. Display a one time login link for the given user account
- user-password. Set the password for the user with the specified name.
- user-remove-role. Remove a role from the specified user accounts.
- user-unblock. Unblock the specified user(s).
Moshe Weitzman (that's me) added 5 commands specific to Drupal 7's Field API. In particular, they try to take some drudgery out of populating a content type with a bunch of Fields. These Drush commands get you started quickly. Some GUI work is often needed to configure the instances, formatters and widgets. The commands are:
- field-clone. Clone a field and all its instances.
- field-create. Create fields and instances. Returns urls for field editing.
- field-delete. Delete a field and its instances.
- field-info. View information about fields, field_types, and widgets.
- field-update. Return URL for field editing web page.
Project Manager (pm)
The beloved project manager commands were enriched significantly during this release cycle. I'd like to thank Jonathan Araña Cruz (jonhattan), who did an awesome job as the maintainer of these commands.
pm-download. This command, better known as
dl, quickly downloads projects from drupal.org or feature servers. In Drush 4, we added:
- --notes option shows release notes after downloading projects.
- --select option asks you to choose from a few recent releases or the development snapshot release. --select --all lets you choose from all available releases for a given version of Drupal.
pm-updatecode. This command updates some or all of your projects to their latest recommended release. In Drush 4 we added:
- --lock. Pin a project at its current release such that pm-updatecode will skip pending updates.
- --security-only. Only update projects that have security releases pending.
- --show release notes after updating projects.
- Drush checks for pending releases of itself and asks you to run selfupdate if any are pending.
pm-uninstall. You may now use wildcards when specifying extensions (aka modules/themes). For example,
drush en views* uc*.
The above commands are now integrated with git.drupal.org so that you can optionally use git clones instead of tarballs. Lets all work together at http://groups.drupal.org/node/93449 so that Drush can help bring consistent, deep git.drupal.org integration to our sites.
We tweaked our SQL commands this release cycle. Perhaps you will enjoy …
sql-dumpgets a new --gzip which compresses your DB backup file.
sql-syncis a jaw dropping time saver., It dumps, transfers, and loads your database from one server to another. new in Drush 4 is --sanitize, an optional phase for stripping sensitive information such as passwords and emails from database. Modules and commandfiles can do additional stripping as needed.
sql-drop. A new command to drop all tables in your current database.
Finally, we added support for SQLite and MSSQL, for those awesome Drupal 7 sites that prefer alternative database platforms.
selfupdate. A new command which updates Drush itself when a new release is pending.
core-cli. A custom shell environment thats optimized for Drush.
—pipe. Show all the nifty .bashrc code that this shell uses so that you import it into your usual shell. Very useful.
image-flush. Delete all image styles (D7 only). A companion command to pre-generate image styles would be nice for Drush 5.
php-script. Drush scripts are a lightweight alternative to Drush commands. Drush commands are not heavy weight at all but CLI developers can be extraordinarily lazy :) ... Scripts may now be standalone files that can be directly called from the CLI. That works because of their shebang line (first line). See examples/helloworld.script for an example. These Drush scripts have easy access to any CLI arguments that were used.
site-install. Programmatically install Drupal 6 (new) or Drupal 7 site. Can use any install profile or language.
site-upgrade. Fully automated upgrade script from Drupal 6 to Drupal 7. Re-run this command over and over as you tweak your update functions and available modules. Saves a lot of time.
test-run. Run some or all of the simpletest tests found in your site.
In addition to those people I've mentioned, thanks to Greg Anderson (greg.1.anderson) for many contributions such as standalone Drush scripts (see
core-cli functionality in your own shell, --sanitize for
sql-sync, and boatloads of documentation. Finally, Mark Sonnabaum (msonnabaum) has accepted my request for him to be the Drush 4 branch maintainer. Thanks for your service, Mark.