protected function execute(InputInterface $input, OutputInterface $output) { $this->satisUpdater->setOutput($output); // get sync manager $composerJsonFile = $input->getArgument('composerJsonFile'); $apiEndpoint = $input->getArgument('apiEndpoint'); $rewrite = $input->getOption('rewrite'); $this->satisUpdater->setComposerJsonFile($composerJsonFile); $this->satisUpdater->setApiEndpoint($apiEndpoint); $this->satisUpdater->update($rewrite); }
/** * Starts processing. * * @param \Elegant\Cli\Io\InputInterface $input * @param \Elegant\Cli\Io\OutputInterface $output */ public final function process(InputInterface $input, OutputInterface $output) { $commandName = $input->getArgument(1); if (null === $commandName) { return; } $command = $this->getCommandCollection()->get($commandName); if (null === $command) { return; } $this->registerCommand($command); $callback = $command->getCallback(); $this->getContainer()->call($callback, [$input, $output]); }
/** * Execute command * * @param InputInterface $input * @param OutputInterface $output * * @return void */ public function execute(InputInterface $input, OutputInterface $output) { try { $command = $input->getArgument('cmd'); switch ($command) { case 'start': $this->start($output); break; case 'stop': $this->stop($output); break; } } catch (\EngineException $e) { $output->writeln(sprintf('<error>%s</error>', $e->getMessage())); } }
/** * {@inheritDoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $logger = new ConsoleLogger($output); $questionAsker = new QuestionAsker($this->getHelper('question'), $input, $output); try { $targetDir = call_user_func_array($this->dirValidatorFactory, [$questionAsker, $this->filesystem])->validateValue($input->getArgument('path')); $data = call_user_func_array($this->dataProviderFactory, [$questionAsker])->getData(); $assets = call_user_func_array($this->assetCollectionFactory, [$this->filesystem, $data]); $assets->exportToDir($targetDir); } catch (\Exception $e) { if ($output->isDebug()) { throw $e; } $logger->error($e->getMessage()); return Application::EXIT_CODE_MAPPING[get_class($e)] ?? Application::EXIT_CODE_UNKOWN_ERROR; } }
protected function marshallInput(InputInterface $input) : string { $inputFile = $input->getArgument('file'); if ($inputFile) { Assertion::file($inputFile); $inputBuffer = file_get_contents($inputFile); } else { $inputBuffer = ''; $stdin = fopen('php://stdin', 'r'); stream_set_blocking($stdin, false); while ($line = fgets($stdin)) { $inputBuffer .= $line; } } Assertion::notEmpty($inputBuffer, 'Input must not be empty'); return $inputBuffer; }
protected function execute(InputInterface $input, OutputInterface $output) { $date = $input->getArgument("expiredDate"); $checkDate = $date instanceof \DateTime ? $date : new \DateTime($date); $checkDate->setTime(0, 0, 0); $em = $this->getContainer()->get('doctrine')->getEntityManager(); $entities = $em->getRepository('BraemCRMBundle:Lead')->deleteExpiredLeads($checkDate); if ($entities) { $count = count($entities); foreach ($entities as $entity) { $em->remove($entity); $output->writeln('Removed lead #' . $entity->getId()); } $em->flush(); $output->writeln($count . ' leads were successfully removing'); } else { $output->writeln('Nothing to remove'); } }
protected function listCommands(InputInterface $input, OutputInterface $output) { $filter = $input->getArgument(1, NULL); $message = $filter === NULL ? '' : ' in namespace [' . $filter . ']'; $output->writeLine("Available commands%s:", $message); $output->writeLine(''); foreach ($this->commands as $namespace => $cmd) { if ($filter !== NULL && $namespace != $filter) { continue; } $output->writeLine($namespace . ':'); foreach ($cmd as $name => $command) { $output->writeLine(' %s - %s', $name, $command->getDescription()); } $output->writeLine(''); } if ($filter === NULL) { $output->writeLine('help - List all available commands.'); $output->writeLine('exit - Terminate the K2 shell.'); } }
/** * Helper method to get input argument * * @param string $name * @return mixed */ public function arg(string $name) { return $this->input->getArgument($name); }