Drush is one of the coolest tools available for Drupal developers. It provides all sorts of commands for assisting in Drupal development, automating workflows and in general making it easier to script various parts of the drupal workflow. But sometimes the commands that come with drush or those available from other modules just don’t quite cut it. Sometimes we need to automate things that are specific to our own site. Drush commands can also be really useful for quick one off data migration tasks and other things that writing a whole module for might just be overkill. In this series we’re going to learn about:
- What a drush command is and where drush finds the commands that it can use
- How to use hook_drush_command in order to tell drush that we want to provide new commands
- How to output data from our command’s using some of the helper functions built in to drush.
- Writing our own custom drush commands
- Passing arguments to a command
- Passing options to a command
- How to prompt the user for input while your command is executing
- Creating policy files for drush
- Creating make files
This series assumes that you’re already familiar with the basics of drush, that you’ve got it installed on your system already and that you’re comfortable with running drush commands provided by core and contrib modules. If you’re not familiar with drush yet you might want to start with the Introduction to Drush Series which covers all of the prerequisites for this series. We will be using the Databasics module, which we have created and used in previous series on Drupalize.Me. The original module was created in the Module Development for Drupal 7 series, and we have extended the module with Views integration in the Coding for Views for Drupal 7 series.