3

I'm creating a custom drush command in my module but it's not being seen. Wondering if someone would know why. The module is enabled. It seems the hook_drush_command() is never being called for my module, but I see it being done for other modules. I've tried clearing cache.

bir.drush.inc is located in /bir/drush directory

function bir_drush_command() {
  $items = array();

  $items['bir-process-images'] = array(
      'description' => dt('Process images on image server.'),
      'aliases' => array('birpi'),
      'arguments' => array(
          'days' => dt('Number of day(s) in the past to begin processing.'),
          'nids' => dt('Comma separated list of node ids to process.'),
      ),
      'required-arguments' => array(1),
      'options' => array(
          'days' => dt('Number of day(s) in the past to begin processing.'),
          'nids' => dt('Comma separated list of node ids to process.'),
      ),
      'examples' => array(
          'drush bir-process-images --days=7' => dt('Process images from 7 days ago to now.'),
          'drush bir-process-images --nids="2409,2309,5896"' => dt('Process images for given node ids.'),
          'drush birpi --days=7' => dt('Process images from 7 days ago to now.'),
          'drush birpi --nids="2409,2309,5896"' => dt('Process images for given node ids.'),
      ),
  );

  return $items;
}

When I type $ drush help at the command line, my command is never shown. I tried printing out the $items array in the function and it never even gets there. If I print $items out in another module, for example search_api, it prints to my screen. So, for some reason it's simply not picking up that I'm calling the hook in my file. Or, not seeing the file?

  • Do you have the same problem if you put the drush.inc file in the root of your module folder? I don't think Drush will automatically traverse sub-folders in a module to look for an include file – Clive Sep 11 '13 at 16:48
  • @Clive - Yes. That is where I had it at first. Then I looked at some other modules and they had it in a drush folder. So tried that as well. – rbruhn Sep 11 '13 at 16:55
1

I figured it out. Even though I closed the command line window, I never cleared the drush cache. Running "$ drush cache-clear drush" fixed the issue.

  • That would do it! You can also use the alias drush cc drush to save time. – jonpeck Oct 24 '13 at 17:59

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.