@@ 200-224 (lines=25) @@ | ||
197 | * |
|
198 | * @return array|false |
|
199 | */ |
|
200 | protected function completeForOptionShortcutValues() |
|
201 | { |
|
202 | $wordIndex = $this->context->getWordIndex(); |
|
203 | ||
204 | if ($this->command && $wordIndex > 1) { |
|
205 | $left = $this->context->getWordAtIndex($wordIndex - 1); |
|
206 | ||
207 | // Complete short options |
|
208 | if ($left[0] == '-' && strlen($left) == 2) { |
|
209 | $shortcut = substr($left, 1); |
|
210 | $def = $this->command->getNativeDefinition(); |
|
211 | ||
212 | if (!$def->hasShortcut($shortcut)) { |
|
213 | return false; |
|
214 | } |
|
215 | ||
216 | $opt = $def->getOptionForShortcut($shortcut); |
|
217 | if ($opt->isValueRequired() || $opt->isValueOptional()) { |
|
218 | return $this->completeOption($opt); |
|
219 | } |
|
220 | } |
|
221 | } |
|
222 | ||
223 | return false; |
|
224 | } |
|
225 | ||
226 | /** |
|
227 | * Attemp to complete the current word as the value of a long-form option |
|
@@ 231-254 (lines=24) @@ | ||
228 | * |
|
229 | * @return array|false |
|
230 | */ |
|
231 | protected function completeForOptionValues() |
|
232 | { |
|
233 | $wordIndex = $this->context->getWordIndex(); |
|
234 | ||
235 | if ($this->command && $wordIndex > 1) { |
|
236 | $left = $this->context->getWordAtIndex($wordIndex - 1); |
|
237 | ||
238 | if (strpos($left, '--') === 0) { |
|
239 | $name = substr($left, 2); |
|
240 | $def = $this->command->getNativeDefinition(); |
|
241 | ||
242 | if (!$def->hasOption($name)) { |
|
243 | return false; |
|
244 | } |
|
245 | ||
246 | $opt = $def->getOption($name); |
|
247 | if ($opt->isValueRequired() || $opt->isValueOptional()) { |
|
248 | return $this->completeOption($opt); |
|
249 | } |
|
250 | } |
|
251 | } |
|
252 | ||
253 | return false; |
|
254 | } |
|
255 | ||
256 | /** |
|
257 | * Attempt to complete the current word as a command name |