/** * Logic that will be executed when command is visited * * @param AbstractCommand $command * @param int $depth * * @return mixed */ function process(AbstractCommand $command, $depth = 0) { if (is_null($this->argumentsContainer->getArgumentAt($this->currentIndex + 2))) { echo $command->getArgument() . ' '; } elseif (StaticStringy::startsWith($command->getArgument(), $this->argumentsContainer->getArgumentAt($this->currentIndex + 2))) { echo $command->getArgument() . ' '; } }
/** * * Handle power up event * * @param SimpleEvent $event * * @throws \ThinFrame\Foundation\Exceptions\Exception */ public function onPowerUp(SimpleEvent $event) { if ($this->argumentsContainer->getArgumentAt(0) == 'compgen') { $this->commander->iterate(new CompletionIterator($this->argumentsContainer)); } else { $this->commander->iterate($executor = new ExecuteIterator($this->argumentsContainer)); if (!$executor->isStopped()) { throw new Exception('Cannot find the command you requested'); } } }
/** * Logic that will be executed when command is visited * * @param AbstractCommand $command * @param int $depth * * @return mixed */ function process(AbstractCommand $command, $depth = 0) { if ($command->getArgument() != $this->argumentsContainer->getArgumentAt($depth)) { return; } if (count($command->getChildCommands()) == 0) { $command->execute($this->argumentsContainer); $this->stop(); } elseif ($this->argumentsContainer->getArgumentsCount() - 1 == $depth) { $command->execute($this->argumentsContainer); $this->stop(); } }
/** * This method will be called if this command is triggered * * @param ArgumentsContainer $arguments * * @return mixed */ public function execute(ArgumentsContainer $arguments) { if ($arguments->getOption('daemon')) { if (!ServerHelper::isRunning()) { Exec::viaPipe('bin/thinframe server start > /dev/null 2>&1 &', KARMA_ROOT); sleep(2); } if (ServerHelper::isRunning()) { $this->outputDriver->send('[success]Server is listening at {host}:{port}[/success]' . PHP_EOL, ['host' => $this->server->getHost(), 'port' => $this->server->getPort()]); exit(0); } else { $this->outputDriver->send('[error]Failed to start server[/error]' . PHP_EOL, [], true); exit(1); } } $this->dispatcher->trigger(new SimpleEvent('thinframe.server.pre_start')); $this->outputDriver->send('[success]Server will start listening at {host}:{port}[/success]' . PHP_EOL, ['host' => $this->server->getHost(), 'port' => $this->server->getPort()]); ServerHelper::savePID(); $this->server->start(); }