Skip to content

Commit e4c61c8

Browse files
ogizanagichalasr
authored andcommitted
Use stderr for some other commands
1 parent 629ff1b commit e4c61c8

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

Command/ConfigDumpReferenceCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ protected function configure()
7474
protected function execute(InputInterface $input, OutputInterface $output)
7575
{
7676
$io = new SymfonyStyle($input, $output);
77+
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
7778

7879
if (null === $name = $input->getArgument('name')) {
79-
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
8080
$this->listBundles($errorIo);
8181
$errorIo->comment(array(
8282
'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>)',
@@ -96,7 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9696
$path = $input->getArgument('path');
9797

9898
if ($path !== null && 'yaml' !== $format) {
99-
$io->error('The "path" option is only available for the "yaml" format.');
99+
$errorIo->error('The "path" option is only available for the "yaml" format.');
100100

101101
return 1;
102102
}

Command/TranslationDebugCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

1414
use Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader;
15+
use Symfony\Component\Console\Output\ConsoleOutputInterface;
1516
use Symfony\Component\Console\Style\SymfonyStyle;
1617
use Symfony\Component\Console\Input\InputInterface;
1718
use Symfony\Component\Console\Input\InputArgument;
@@ -159,7 +160,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
159160
$outputMessage .= sprintf(' and domain "%s"', $domain);
160161
}
161162

162-
$io->warning($outputMessage);
163+
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
164+
$errorIo->warning($outputMessage);
163165

164166
return;
165167
}

Command/TranslationUpdateCommand.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

14+
use Symfony\Component\Console\Output\ConsoleOutputInterface;
1415
use Symfony\Component\Console\Style\SymfonyStyle;
1516
use Symfony\Component\Translation\Catalogue\TargetOperation;
1617
use Symfony\Component\Translation\Catalogue\MergeOperation;
@@ -85,10 +86,11 @@ public function isEnabled()
8586
protected function execute(InputInterface $input, OutputInterface $output)
8687
{
8788
$io = new SymfonyStyle($input, $output);
89+
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
8890

8991
// check presence of force or dump-message
9092
if ($input->getOption('force') !== true && $input->getOption('dump-messages') !== true) {
91-
$io->error('You must choose one of --force or --dump-messages');
93+
$errorIo->error('You must choose one of --force or --dump-messages');
9294

9395
return 1;
9496
}
@@ -97,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9799
$writer = $this->getContainer()->get('translation.writer');
98100
$supportedFormats = $writer->getFormats();
99101
if (!in_array($input->getOption('output-format'), $supportedFormats)) {
100-
$io->error(array('Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.'));
102+
$errorIo->error(array('Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.'));
101103

102104
return 1;
103105
}
@@ -127,12 +129,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
127129
}
128130
}
129131

130-
$io->title('Translation Messages Extractor and Dumper');
131-
$io->comment(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $currentName));
132+
$errorIo->title('Translation Messages Extractor and Dumper');
133+
$errorIo->comment(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $currentName));
132134

133135
// load any messages from templates
134136
$extractedCatalogue = new MessageCatalogue($input->getArgument('locale'));
135-
$io->comment('Parsing templates...');
137+
$errorIo->comment('Parsing templates...');
136138
$extractor = $this->getContainer()->get('translation.extractor');
137139
$extractor->setPrefix($input->getOption('no-prefix') ? '' : $input->getOption('prefix'));
138140
foreach ($transPaths as $path) {
@@ -144,7 +146,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
144146

145147
// load any existing messages from the translation files
146148
$currentCatalogue = new MessageCatalogue($input->getArgument('locale'));
147-
$io->comment('Loading translation files...');
149+
$errorIo->comment('Loading translation files...');
148150
$loader = $this->getContainer()->get('translation.loader');
149151
foreach ($transPaths as $path) {
150152
$path .= 'translations';
@@ -165,7 +167,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
165167

166168
// Exit if no messages found.
167169
if (!count($operation->getDomains())) {
168-
$io->warning('No translation messages were found.');
170+
$errorIo->warning('No translation messages were found.');
169171

170172
return;
171173
}
@@ -199,7 +201,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
199201
}
200202

201203
if ($input->getOption('output-format') == 'xlf') {
202-
$io->comment('Xliff output version is <info>1.2</info>');
204+
$errorIo->comment('Xliff output version is <info>1.2</info>');
203205
}
204206

205207
$resultMessage = sprintf('%d message%s successfully extracted', $extractedMessagesCount, $extractedMessagesCount > 1 ? 's were' : ' was');
@@ -211,7 +213,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
211213

212214
// save the files
213215
if ($input->getOption('force') === true) {
214-
$io->comment('Writing files...');
216+
$errorIo->comment('Writing files...');
215217

216218
$bundleTransPath = false;
217219
foreach ($transPaths as $path) {
@@ -232,7 +234,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
232234
}
233235
}
234236

235-
$io->success($resultMessage.'.');
237+
$errorIo->success($resultMessage.'.');
236238
}
237239

238240
private function filterCatalogue(MessageCatalogue $catalogue, $domain)

0 commit comments

Comments
 (0)