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