function _drush_find_commandfiles_drush

8.0.x _drush_find_commandfiles_drush()
7.x _drush_find_commandfiles_drush()
master _drush_find_commandfiles_drush()
1 call to _drush_find_commandfiles_drush()
drush_preflight in includes/
During the initialization of Drush, this is the first step where we load our configuration and commandfiles, and select the site we are going to operate on; however, we take no irreversible actions (e.g. site bootstrapping). This allows commands that…


includes/, line 473
Preflight, postflight and shutdown code.


function _drush_find_commandfiles_drush() {
  // Core commands shipping with Drush
  $searchpath[] = dirname(__FILE__) . '/../commands/';

  // User commands, specified by 'include' option
  $include = drush_get_context('DRUSH_INCLUDE', array());
  foreach ($include as $path) {
    if (is_dir($path)) {
      drush_log('Include ' . $path, LogLevel::NOTICE);
      $searchpath[] = $path;

  if (!drush_get_option('local')) {
    // System commands, residing in $SHARE_PREFIX/share/drush/commands
    $share_path = drush_get_context('DRUSH_SITE_WIDE_COMMANDFILES');
    if (is_dir($share_path)) {
      $searchpath[] = $share_path;

    // User commands, residing in ~/.drush
    $per_user_config_dir = drush_get_context('DRUSH_PER_USER_CONFIGURATION');
    if (!empty($per_user_config_dir)) {
      $searchpath[] = $per_user_config_dir;

  // @todo the zero parameter is a bit weird here. It's $phase.
  _drush_add_commandfiles($searchpath, 0);