Esempio n. 1
0
 public function getCompletionTestInput()
 {
     $options = array('smooth', 'latin', 'moody');
     return array('command match' => array(new Completion('wave', 'target', Completion::ALL_TYPES, $options), array('app walk:north --target ' => array(), 'app wave ' => $options)), 'type restriction option' => array(new Completion(Completion::ALL_COMMANDS, 'target', Completion::TYPE_OPTION, $options), array('app walk:north --target ' => $options, 'app wave ' => array())), 'type restriction argument' => array(new Completion(Completion::ALL_COMMANDS, 'target', Completion::TYPE_ARGUMENT, $options), array('app walk:north --target ' => array(), 'app wave ' => $options)), 'makeGlobalHandler static' => array(Completion::makeGlobalHandler('target', Completion::ALL_TYPES, $options), array('app walk:north --target ' => $options, 'app wave ' => $options)), 'with anonymous function' => array(new Completion('wave', 'style', Completion::TYPE_OPTION, function () {
         return range(1, 5);
     }), array('app walk:north --target ' => array(), 'app wave ' => array(), 'app wave --style ' => array(1, 2, 3, 4, 5))), 'with callable array' => array(new Completion(Completion::ALL_COMMANDS, 'target', Completion::ALL_TYPES, array($this, 'instanceMethodForCallableCheck')), array('app walk:north --target ' => array('hello', 'world'), 'app wave ' => array('hello', 'world'))), 'multiple handlers' => array(array(new Completion(Completion::ALL_COMMANDS, 'target', Completion::TYPE_OPTION, array('all:option:target')), new Completion(Completion::ALL_COMMANDS, 'target', Completion::ALL_TYPES, array('all:all:target')), new Completion(Completion::ALL_COMMANDS, 'style', Completion::TYPE_OPTION, array('all:option:style'))), array('app walk:north ' => array(), 'app walk:north -t ' => array('all:option:target'), 'app wave ' => array('all:all:target'), 'app wave bruce -s ' => array('all:option:style'), 'app walk:north --style ' => array('all:option:style'))));
 }
 /**
  * @inheritdoc
  */
 protected function runCompletion()
 {
     $this->setUp();
     $projectIds = array_keys($this->projects);
     $this->handler->addHandlers(array(new Completion('project:get', 'id', Completion::TYPE_ARGUMENT, $projectIds), Completion::makeGlobalHandler('project', Completion::TYPE_OPTION, $projectIds), Completion::makeGlobalHandler('environment', Completion::TYPE_ARGUMENT, array($this, 'getEnvironments')), Completion::makeGlobalHandler('environment', Completion::TYPE_OPTION, array($this, 'getEnvironments')), new Completion('environment:branch', 'parent', Completion::TYPE_ARGUMENT, array($this, 'getEnvironments')), new Completion('environment:checkout', 'id', Completion::TYPE_ARGUMENT, array($this, 'getEnvironmentsForCheckout')), new Completion\ShellPathCompletion('ssh-key:add', 'path', Completion::TYPE_ARGUMENT), new Completion\ShellPathCompletion('domain:add', 'cert', Completion::TYPE_OPTION), new Completion\ShellPathCompletion('domain:add', 'key', Completion::TYPE_OPTION), new Completion\ShellPathCompletion('domain:add', 'chain', Completion::TYPE_OPTION), new Completion\ShellPathCompletion('local:build', 'source', Completion::TYPE_OPTION), new Completion\ShellPathCompletion('local:build', 'destination', Completion::TYPE_OPTION), new Completion\ShellPathCompletion('environment:sql-dump', 'file', Completion::TYPE_OPTION), new Completion\ShellPathCompletion('local:init', 'directory', Completion::TYPE_ARGUMENT)));
     try {
         return $this->handler->runCompletion();
     } catch (\Exception $e) {
         // Suppress exceptions so that they are not displayed during
         // completion.
     }
     return [];
 }