Return a word by index from the command line
public getWordAtIndex ( integer $index ) : string | ||
$index | integer | |
Résultat | string |
/** * Attemp to complete the current word as the value of a long-form option * * @return array|false */ protected function completeForOptionValues() { $wordIndex = $this->context->getWordIndex(); if ($this->command && $wordIndex > 1) { $left = $this->context->getWordAtIndex($wordIndex - 1); if (strpos($left, '--') === 0) { $name = substr($left, 2); $def = $this->command->getNativeDefinition(); if (!$def->hasOption($name)) { return false; } $opt = $def->getOption($name); if ($opt->isValueRequired() || $opt->isValueOptional()) { return $this->completeOption($opt); } } } return false; }
/** * {@inheritdoc} */ public function completeArgumentValues($argumentName, CompletionContext $context) { $aliases = []; if ($argumentName === 'issue_number') { // Get all the aliases that are similar to our current search. $results = $this->repository->listAliases($context->getWordAtIndex(2)); foreach ($results as $alias) { $aliases[] = $alias->alias; } } return $aliases; }