/** * Executes this application. * * @param bool $interactive runs in an interactive shell if true. * * @return void */ public function run($interactive = false) { $app = $this['console']; if ($interactive) { $app = new Console\Shell($app); } $app->run(); }
public function doRun(InputInterface $input, OutputInterface $output) { if (true === $input->hasParameterOption(array('--shell', '-s'))) { $shell = new Shell($this); $shell->setProcessIsolation($input->hasParameterOption(array('--process-isolation'))); $shell->run(); return 0; } return parent::doRun($input, $output); }
/** * {@inheritdoc} */ public function doRun(InputInterface $input, OutputInterface $output) { // Run a shell if the --shell (or -s) option is set and if no command name is specified // Also, we do not want to have the --shell option available if we are already in a shell if (!$this->in_shell && $this->getCommandName($input) === null && $input->hasParameterOption(array('--shell', '-s'))) { $shell = new Shell($this); $this->in_shell = true; $shell->run(); return 0; } return parent::doRun($input, $output); }
/** * Runs the current application. * * @param InputInterface $input An Input instance * @param OutputInterface $output An Output instance * * @return integer 0 if everything went fine, or an error code */ public function doRun(InputInterface $input, OutputInterface $output) { $output->writeLn($this->getHeader()); $name = $this->getCommandName($input); if (true === $input->hasParameterOption(array('--shell', '-s'))) { $shell = new Shell($this); $shell->run(); return 0; } if (true === $input->hasParameterOption(array('--ansi'))) { $output->setDecorated(true); } elseif (true === $input->hasParameterOption(array('--no-ansi'))) { $output->setDecorated(false); } if (true === $input->hasParameterOption(array('--help', '-h'))) { if (!$name) { $name = 'help'; $input = new ArrayInput(array('command' => 'help')); } else { $this->wantHelps = true; } } if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) { $input->setInteractive(false); } if (function_exists('posix_isatty') && $this->getHelperSet()->has('dialog')) { $inputStream = $this->getHelperSet()->get('dialog')->getInputStream(); if (!posix_isatty($inputStream)) { $input->setInteractive(false); } } if (true === $input->hasParameterOption(array('--quiet', '-q'))) { $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); } elseif (true === $input->hasParameterOption(array('--verbose', '-v'))) { $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); } if (true === $input->hasParameterOption(array('--version', '-V'))) { $output->writeln($this->getLongVersion()); return 0; } if (!$name) { $name = 'list'; $input = new ArrayInput(array('command' => 'list')); } // the command name MUST be the first element of the input $command = $this->find($name); $this->runningCommand = $command; $statusCode = $command->run($input, $output); $this->runningCommand = null; # write Footer $output->writeLn($this->getFooter()); return is_numeric($statusCode) ? $statusCode : 0; }
public function doRun(InputInterface $input, OutputInterface $output) { $this->kernel->boot(); if (!$this->registered) { $this->registerCommands(); $this->registered = true; } foreach ($this->all() as $command) { if ($command instanceof ContainerAwareInterface) { $command->setContainer($this->container); } } if (true === $input->hasParameterOption(array('--shell', '-s'))) { $shell = new Shell($this); $shell->setProcessIsolation($input->hasParameterOption(array('--process-isolation'))); $shell->run(); return 0; } return parent::doRun($input, $output); }
/** * {@inheritdoc} */ public function doRun(InputInterface $input, OutputInterface $output) { // Set the input to non-interactive if the yes or no options are used. if ($input->hasParameterOption(array('--yes', '-y')) || $input->hasParameterOption(array('--no', '-n'))) { $input->setInteractive(false); } elseif ($input->hasParameterOption(array('--shell', '-s'))) { $shell = new Shell($this); $shell->run(); return 0; } return parent::doRun($input, $output); }
/** * Run the application and if no command is provided, use project:run. * * @param bool $interactive Whether to run in interactive mode. * * @return void */ public function run($interactive = false) { /** @var ConsoleApplication $app */ $app = $this['console']; $app->setAutoExit(false); if ($interactive) { $app = new Shell($app); } $output = new Console\Output\Output(); $output->setLogger($this['monolog']); $app->run(new ArgvInput(), $output); }
protected function execute(InputInterface $input, OutputInterface $output) { $shell = new Shell($this->getApplication()); $shell->run(); }
#!/usr/bin/php <?php // Require composer autoloader require_once __DIR__ . '/vendor/autoload.php'; use Symfony\Component\Console; // Create twitter service $dataStore = new Ornithology\Service\DataStoreFile(getenv('HOME') . '/.ornithology'); $twitterService = new Ornithology\Service\Twitter($dataStore); // Initialize the application $application = new Console\Application('Ornithology', '0.0.3'); // Add application related commands $application->add(new Ornithology\Command\Quit('exit')); $application->add(new Ornithology\Command\Mark('mark')); // Add twitter related commands $application->add(new Ornithology\Command\Authorize('authorize', $twitterService)); $application->add(new Ornithology\Command\Refresh('refresh', $twitterService)); $application->add(new Ornithology\Command\Tweet('tweet', $twitterService)); $application->add(new Ornithology\Command\Reply('reply', $twitterService)); $application->add(new Ornithology\Command\Retweet('retweet', $twitterService)); $application->add(new Ornithology\Command\Favorite('favorite', $twitterService)); $application->add(new Ornithology\Command\Urls('urls', $twitterService)); // Set some defaults $application->setDefaultCommand('mark'); // Run the application as a shell $shell = new Console\Shell($application); $shell->run();
/** * Execute the Slic Application. * * @param bool $interactive Run this application interactively or not? */ public function run($interactive = false) { $app = $this->container->get('console'); if ($interactive) { $app = new Console\Shell($app); } $app->run(); }