function drush_complete_get

8.0.x complete.inc drush_complete_get($type, $command = NULL)
6.x complete.inc drush_complete_get($type, $command = NULL)
7.x complete.inc drush_complete_get($type, $command = NULL)
5.x complete.inc drush_complete_get($type, $command = NULL)
master complete.inc drush_complete_get($type, $command = NULL)

Retrieves from cache, or generates a listing of completion candidates of a specific type (and optionally, command).

Parameters

string $type: String indicating type of completions to return. See drush_complete_rebuild() for possible keys.

string $command: An optional command name if command specific completion is needed.

Return value

array List of candidate completions.

1 call to drush_complete_get()
drush_early_complete in includes/complete.inc
Produce autocomplete output.

File

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

Code

function drush_complete_get($type, $command = NULL) {
  if (empty($command)) {
    // Retrieve global items from a non-command specific cache, or rebuild cache
    // if needed.
    $cache = drush_cache_get(drush_complete_cache_cid($type), 'complete');
    if (isset($cache->data)) {
      return $cache->data;
    }
    $complete = drush_complete_rebuild();
    return $complete[$type];
  }
  // Retrieve items from a command specific cache.
  $cache = drush_cache_get(drush_complete_cache_cid($type, $command), 'complete');
  if (isset($cache->data)) {
    return $cache->data;
  }
  // Build argument cache - built only on demand.
  if ($type == 'arguments') {
    return drush_complete_rebuild_arguments($command);
  }
  // Rebuild cache of general command specific items.
  $complete = drush_complete_rebuild();
  if (!empty($complete['commands'][$command][$type])) {
    return $complete['commands'][$command][$type];
  }
  return array();
}