function drush_complete_rebuild

8.0.x complete.inc drush_complete_rebuild()
6.x complete.inc drush_complete_rebuild()
7.x complete.inc drush_complete_rebuild()
5.x complete.inc drush_complete_rebuild()
master complete.inc drush_complete_rebuild()

Rebuild and cache completions for everything except command arguments.

Return value

array Structured array of completion types, commands and candidate completions.

1 call to drush_complete_rebuild()
drush_complete_get in includes/complete.inc
Retrieves from cache, or generates a listing of completion candidates of a specific type (and optionally, command).

File

includes/complete.inc, line 412
Provide completion output for shells.

Code

function drush_complete_rebuild() {
  $complete = array();
  // Bootstrap to the site level (if possible) - commands may need to check
  // the bootstrap level, and perhaps bootstrap higher in extraordinary cases.
  drush_bootstrap_max(DRUSH_BOOTSTRAP_DRUPAL_SITE);
  $commands = drush_get_commands();
  foreach ($commands as $command_name => $command) {
    // Add command options and suboptions.
    $options = array_keys($command['options']);
    foreach ($command['sub-options'] as $option => $sub_options) {
      $options = array_merge($options, array_keys($sub_options));
    }
    $complete['commands'][$command_name]['options'] = $options;
  }
  // We treat shell aliases as commands for the purposes of completion.
  $complete['command-names'] = array_merge(array_keys($commands), array_keys(drush_get_context('shell-aliases', array())));
  $site_aliases = _drush_sitealias_all_list();
  // TODO: Figure out where this dummy @0 alias is introduced.
  unset($site_aliases['@0']);
  $complete['site-aliases'] = array_keys($site_aliases);
  $complete['options'] = array_keys(drush_get_global_options());

  // We add a space following all completes. Eventually there may be some
  // items (e.g. options that we know need values) where we don't add a space.
  array_walk_recursive($complete, 'drush_complete_trailing_space');
  drush_complete_cache_set($complete);
  return $complete;
}