I want to implement my own Drush command, and struggle because while the "Make me a sandwich" example is very good, it's also quite complex, and for someone that has never made such an extension it's easy to loose track of what is mandatory, and what is optional.

I would like to see a basic Drush extension implementation.


This is valid for Drush >= 4

 * @file EXAMPLE.drush.inc
 * Provides a simple drush extension example

function EXAMPLE_drush_command() {
  return array('COMMANDNAME' =>
      'description' => 'My example command',
      'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,

function drush_COMMANDNAME_validate() {
  // Return
  // drush_set_error('MACHINE_NAME_OF_FAIL', dt('Command failed because [reason]'));
  // on error.

function drush_COMMANDNAME() {
  echo 'Extension working!';
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.