Skip to content

Instantly share code, notes, and snippets.

@smhnaji
Last active February 15, 2020 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smhnaji/cd64ba65b6c711d6f2bb072d9fb9b310 to your computer and use it in GitHub Desktop.
Save smhnaji/cd64ba65b6c711d6f2bb072d9fb9b310 to your computer and use it in GitHub Desktop.
Simplest Drupal 7 drush command
<?php
// This file is belonged to a module called x.
// It's all devoted to the drush commands related to the module.
/**
* Define the drush commands' interface
*/
function x_drush_command()
{
$items['great-action'] = [
'description' => 'Description of the new perfect command!',
];
return $items;
}
/*
* Implement the great-action logic
*/
function drush_x_great_action()
{
drupal_set_message(t('Hello World from the newly defined perfect action!'));
}
@smhnaji
Copy link
Author

smhnaji commented Feb 15, 2020

After adding the file, you should...

drush cc all
drush great-action

And we expect the output:

Hello World from the newly defined perfect action!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment