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