[FrameworkBundle] Make use of stderr for non reliable output
This commit is contained in:
parent
136a5ffc55
commit
1ee48bfd60
@ -87,9 +87,7 @@ EOF
|
|||||||
$twig = $this->getTwigEnvironment();
|
$twig = $this->getTwigEnvironment();
|
||||||
|
|
||||||
if (null === $twig) {
|
if (null === $twig) {
|
||||||
$io->error('The Twig environment needs to be set.');
|
throw new \RuntimeException('The Twig environment needs to be set.');
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$types = array('functions', 'filters', 'tests', 'globals');
|
$types = array('functions', 'filters', 'tests', 'globals');
|
||||||
|
@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
|||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
use Symfony\Component\Finder\Finder;
|
use Symfony\Component\Finder\Finder;
|
||||||
|
|
||||||
@ -88,9 +89,7 @@ EOF
|
|||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
if (null === $twig = $this->getTwigEnvironment()) {
|
if (null === $twig = $this->getTwigEnvironment()) {
|
||||||
$io->error('The Twig environment needs to be set.');
|
throw new \RuntimeException('The Twig environment needs to be set.');
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$filenames = $input->getArgument('filename');
|
$filenames = $input->getArgument('filename');
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Component\Config\Definition\Processor;
|
|||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
use Symfony\Component\Console\Exception\LogicException;
|
use Symfony\Component\Console\Exception\LogicException;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
@ -62,11 +63,12 @@ EOF
|
|||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
|
||||||
|
|
||||||
if (null === $name = $input->getArgument('name')) {
|
if (null === $name = $input->getArgument('name')) {
|
||||||
$this->listBundles($io);
|
$this->listBundles($errorIo);
|
||||||
$io->comment('Provide the name of a bundle as the first argument of this command to dump its configuration. (e.g. <comment>debug:config FrameworkBundle</comment>)');
|
$errorIo->comment('Provide the name of a bundle as the first argument of this command to dump its configuration. (e.g. <comment>debug:config FrameworkBundle</comment>)');
|
||||||
$io->comment('For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>debug:config FrameworkBundle serializer</comment> to dump the <comment>framework.serializer</comment> configuration)');
|
$errorIo->comment('For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>debug:config FrameworkBundle serializer</comment> to dump the <comment>framework.serializer</comment> configuration)');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -98,7 +100,7 @@ EOF
|
|||||||
try {
|
try {
|
||||||
$config = $this->getConfigForPath($config, $path, $extensionAlias);
|
$config = $this->getConfigForPath($config, $path, $extensionAlias);
|
||||||
} catch (LogicException $e) {
|
} catch (LogicException $e) {
|
||||||
$io->error($e->getMessage());
|
$errorIo->error($e->getMessage());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
|||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,7 +56,7 @@ this is either <comment>yaml</comment> or <comment>xml</comment>.
|
|||||||
When the option is not provided, <comment>yaml</comment> is used.
|
When the option is not provided, <comment>yaml</comment> is used.
|
||||||
|
|
||||||
<info>php %command.full_name% FrameworkBundle --format=xml</info>
|
<info>php %command.full_name% FrameworkBundle --format=xml</info>
|
||||||
|
|
||||||
For dumping a specific option, add its path as second argument (only available for the yaml format):
|
For dumping a specific option, add its path as second argument (only available for the yaml format):
|
||||||
|
|
||||||
<info>php %command.full_name% framework profiler.matcher</info>
|
<info>php %command.full_name% framework profiler.matcher</info>
|
||||||
@ -75,8 +76,9 @@ EOF
|
|||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
if (null === $name = $input->getArgument('name')) {
|
if (null === $name = $input->getArgument('name')) {
|
||||||
$this->listBundles($io);
|
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
|
||||||
$io->comment(array(
|
$this->listBundles($errorIo);
|
||||||
|
$errorIo->comment(array(
|
||||||
'Provide the name of a bundle as the first argument of this command to dump its default configuration. (e.g. <comment>config:dump-reference FrameworkBundle</comment>)',
|
'Provide the name of a bundle as the first argument of this command to dump its default configuration. (e.g. <comment>config:dump-reference FrameworkBundle</comment>)',
|
||||||
'For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>config:dump-reference FrameworkBundle profiler.matcher</comment> to dump the <comment>framework.profiler.matcher</comment> configuration)',
|
'For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>config:dump-reference FrameworkBundle profiler.matcher</comment> to dump the <comment>framework.profiler.matcher</comment> configuration)',
|
||||||
));
|
));
|
||||||
|
@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
|||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
@ -94,6 +95,8 @@ EOF
|
|||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
|
||||||
|
|
||||||
$this->validateInput($input);
|
$this->validateInput($input);
|
||||||
$object = $this->getContainerBuilder();
|
$object = $this->getContainerBuilder();
|
||||||
|
|
||||||
@ -111,7 +114,7 @@ EOF
|
|||||||
} elseif ($tag = $input->getOption('tag')) {
|
} elseif ($tag = $input->getOption('tag')) {
|
||||||
$options = array('tag' => $tag, 'show_private' => $input->getOption('show-private'));
|
$options = array('tag' => $tag, 'show_private' => $input->getOption('show-private'));
|
||||||
} elseif ($name = $input->getArgument('name')) {
|
} elseif ($name = $input->getArgument('name')) {
|
||||||
$name = $this->findProperServiceName($input, $io, $object, $name);
|
$name = $this->findProperServiceName($input, $errorIo, $object, $name);
|
||||||
$options = array('id' => $name);
|
$options = array('id' => $name);
|
||||||
} else {
|
} else {
|
||||||
$options = array('show_private' => $input->getOption('show-private'));
|
$options = array('show_private' => $input->getOption('show-private'));
|
||||||
@ -122,15 +125,15 @@ EOF
|
|||||||
$options['show_arguments'] = $input->getOption('show-arguments');
|
$options['show_arguments'] = $input->getOption('show-arguments');
|
||||||
$options['raw_text'] = $input->getOption('raw');
|
$options['raw_text'] = $input->getOption('raw');
|
||||||
$options['output'] = $io;
|
$options['output'] = $io;
|
||||||
$helper->describe($output, $object, $options);
|
$helper->describe($io, $object, $options);
|
||||||
|
|
||||||
if (!$input->getArgument('name') && !$input->getOption('tag') && !$input->getOption('parameter') && $input->isInteractive()) {
|
if (!$input->getArgument('name') && !$input->getOption('tag') && !$input->getOption('parameter') && $input->isInteractive()) {
|
||||||
if ($input->getOption('tags')) {
|
if ($input->getOption('tags')) {
|
||||||
$io->comment('To search for a specific tag, re-run this command with a search term. (e.g. <comment>debug:container --tag=form.type</comment>)');
|
$errorIo->comment('To search for a specific tag, re-run this command with a search term. (e.g. <comment>debug:container --tag=form.type</comment>)');
|
||||||
} elseif ($input->getOption('parameters')) {
|
} elseif ($input->getOption('parameters')) {
|
||||||
$io->comment('To search for a specific parameter, re-run this command with a search term. (e.g. <comment>debug:container --parameter=kernel.debug</comment>)');
|
$errorIo->comment('To search for a specific parameter, re-run this command with a search term. (e.g. <comment>debug:container --parameter=kernel.debug</comment>)');
|
||||||
} else {
|
} else {
|
||||||
$io->comment('To search for a specific service, re-run this command with a search term. (e.g. <comment>debug:container log</comment>)');
|
$errorIo->comment('To search for a specific service, re-run this command with a search term. (e.g. <comment>debug:container log</comment>)');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
|||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
@ -65,7 +66,8 @@ EOF
|
|||||||
$options = array();
|
$options = array();
|
||||||
if ($event = $input->getArgument('event')) {
|
if ($event = $input->getArgument('event')) {
|
||||||
if (!$dispatcher->hasListeners($event)) {
|
if (!$dispatcher->hasListeners($event)) {
|
||||||
$io->warning(sprintf('The event "%s" does not have any registered listeners.', $event));
|
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
|
||||||
|
$errorIo->warning(sprintf('The event "%s" does not have any registered listeners.', $event));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ EOF
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);
|
||||||
|
|
||||||
if (null === $documentRoot = $input->getOption('docroot')) {
|
if (null === $documentRoot = $input->getOption('docroot')) {
|
||||||
if (!$this->documentRoot) {
|
if (!$this->documentRoot) {
|
||||||
|
@ -17,6 +17,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
|||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,7 +80,7 @@ EOF
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$io = new SymfonyStyle($input, $cliOutput = $output);
|
$io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);
|
||||||
|
|
||||||
if (!extension_loaded('pcntl')) {
|
if (!extension_loaded('pcntl')) {
|
||||||
$io->error(array(
|
$io->error(array(
|
||||||
@ -88,7 +89,7 @@ EOF
|
|||||||
));
|
));
|
||||||
|
|
||||||
if ($io->ask('Do you want to execute <info>server:run</info> immediately? [yN] ', false)) {
|
if ($io->ask('Do you want to execute <info>server:run</info> immediately? [yN] ', false)) {
|
||||||
return $this->getApplication()->find('server:run')->run($input, $cliOutput);
|
return $this->getApplication()->find('server:run')->run($input, $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Bundle\WebServerBundle\WebServer;
|
|||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +45,7 @@ class ServerStatusCommand extends ServerCommand
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);
|
||||||
$server = new WebServer();
|
$server = new WebServer();
|
||||||
if ($server->isRunning($input->getOption('pidfile'))) {
|
if ($server->isRunning($input->getOption('pidfile'))) {
|
||||||
$io->success(sprintf('Web server still listening on http://%s', $server->getAddress($input->getOption('pidfile'))));
|
$io->success(sprintf('Web server still listening on http://%s', $server->getAddress($input->getOption('pidfile'))));
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\WebServerBundle\Command;
|
|||||||
use Symfony\Bundle\WebServerBundle\WebServer;
|
use Symfony\Bundle\WebServerBundle\WebServer;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ EOF
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$server = new WebServer();
|
$server = new WebServer();
|
||||||
|
Reference in New Issue
Block a user