/** * @return \Components\Test_Cli */ public static function get() { $instance = new static(); $year = date('Y'); $version = (string) Runtime::version(); $instance->addOption('p', true, null, 'test root path', 'path'); $instance->addOption('b', true, null, 'build path', 'build'); $instance->addOption('c', true, null, 'configuration path', 'config'); $instance->addEmptyOption(); $instance->addOption('a', true, null, 'enable static code analyzers [emma,..]', 'analyzers'); $instance->addEmptyOption(); $instance->addOption('h', false, null, 'print command line instructions', 'help'); $instance->addOption('v', false, null, 'print program version & license', 'version'); $instance->setInfo(sprintf('%1$s%3$s%2$s%3$s', "Test Executor {$version}, net.evalcode.components", "Copyright (C) {$year} evalcode.net", Io::LINE_SEPARATOR_DEFAULT)); return $instance; }
/** * Add an argument(sub command) setting. * * @param string|AbstractCommand $command The argument name or Console object. * If we just send a string, the object will auto create. * @param null $description Console description. * @param array $options Console options. * @param \Closure $code The closure to execute. * * @return AbstractCommand Return this object to support chaining. * * @since 1.0 */ public function addCommand($command, $description = null, $options = array(), \Closure $code = null) { if (!$command instanceof AbstractCommand) { $command = new static($command, $this->input, $this->output, $this); } // Set argument detail $command->setApplication($this->application)->setInput($this->input); if ($description !== null) { $command->setDescription($description); } if (count($options)) { $command->setOptions($options); } if ($code) { $command->setHandler($code); } // Set parent $command->setParent($this); // Set global options to sub command /** @var $option Option */ foreach ($this->globalOptions as $option) { $command->addOption($option); } $name = $command->getName(); $this->children[$name] = $command; return $this; }