1<?php
2
3namespace Tiki\Command;
4
5use Symfony\Component\Console\Application as SymfonyApplication;
6use Symfony\Component\Console\Command\Command;
7use Symfony\Component\Console\Input\InputDefinition;
8use Symfony\Component\Console\Input\InputInterface;
9use Symfony\Component\Console\Input\InputOption;
10use Symfony\Component\Console\Output\OutputInterface;
11
12class Application extends SymfonyApplication
13{
14	/**
15	 * Gets the default input definition.
16	 *
17	 * @return InputDefinition An InputDefinition instance
18	 */
19	protected function getDefaultInputDefinition()
20	{
21		$definition = parent::getDefaultInputDefinition();
22		$definition->addOption(new InputOption('--site', '', InputOption::VALUE_REQUIRED, 'Multi-Tiki instance'));
23		$definition->addOption(new InputOption('--as-user', '', InputOption::VALUE_REQUIRED, 'Run the command as a different Tiki user'));
24
25		return $definition;
26	}
27
28	/**
29	 * Runs the current command.
30	 *
31	 * Calls the parent method then prints all Tiki Feedback (errors and messages) to the console
32	 *
33	 * @param Command         $command
34	 * @param InputInterface  $input
35	 * @param OutputInterface $output
36	 *
37	 * @return int 0 if everything went fine, or an error code
38	 * @throws \Throwable
39	 */
40	protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
41	{
42		$exitCode = parent::doRunCommand($command, $input, $output);
43
44		\Feedback::printToConsole($output);
45
46		return $exitCode;
47	}
48}
49