private function Shell::autocompleter in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/console/Shell.php \Symfony\Component\Console\Shell::autocompleter()
 
Tries to return autocompletion for the current entered text.
Parameters
string $text The last segment of the entered text:
Return value
bool|array A list of guessed strings or true
File
- vendor/
symfony/ console/ Shell.php, line 168  
Class
- Shell
 - A Shell wraps an Application to add shell capabilities to it.
 
Namespace
Symfony\Component\ConsoleCode
private function autocompleter($text) {
  $info = readline_info();
  $text = substr($info['line_buffer'], 0, $info['end']);
  if ($info['point'] !== $info['end']) {
    return true;
  }
  // task name?
  if (false === strpos($text, ' ') || !$text) {
    return array_keys($this->application
      ->all());
  }
  // options and arguments?
  try {
    $command = $this->application
      ->find(substr($text, 0, strpos($text, ' ')));
  } catch (\Exception $e) {
    return true;
  }
  $list = array(
    '--help',
  );
  foreach ($command
    ->getDefinition()
    ->getOptions() as $option) {
    $list[] = '--' . $option
      ->getName();
  }
  return $list;
}