Use stderr for some other commands
This commit is contained in:
parent
1ee48bfd60
commit
9a3a5686c8
@ -16,7 +16,6 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
|
@ -74,9 +74,9 @@ EOF
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
|
||||
|
||||
if (null === $name = $input->getArgument('name')) {
|
||||
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
|
||||
$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>)',
|
||||
@ -96,7 +96,7 @@ EOF
|
||||
$path = $input->getArgument('path');
|
||||
|
||||
if ($path !== null && 'yaml' !== $format) {
|
||||
$io->error('The "path" option is only available for the "yaml" format.');
|
||||
$errorIo->error('The "path" option is only available for the "yaml" format.');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Bundle\FrameworkBundle\Command;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
@ -159,7 +160,8 @@ EOF
|
||||
$outputMessage .= sprintf(' and domain "%s"', $domain);
|
||||
}
|
||||
|
||||
$io->warning($outputMessage);
|
||||
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
|
||||
$errorIo->warning($outputMessage);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Translation\Catalogue\TargetOperation;
|
||||
use Symfony\Component\Translation\Catalogue\MergeOperation;
|
||||
@ -85,10 +86,11 @@ EOF
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
|
||||
|
||||
// check presence of force or dump-message
|
||||
if ($input->getOption('force') !== true && $input->getOption('dump-messages') !== true) {
|
||||
$io->error('You must choose one of --force or --dump-messages');
|
||||
$errorIo->error('You must choose one of --force or --dump-messages');
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -97,7 +99,7 @@ EOF
|
||||
$writer = $this->getContainer()->get('translation.writer');
|
||||
$supportedFormats = $writer->getFormats();
|
||||
if (!in_array($input->getOption('output-format'), $supportedFormats)) {
|
||||
$io->error(array('Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.'));
|
||||
$errorIo->error(array('Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.'));
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -127,12 +129,12 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
$io->title('Translation Messages Extractor and Dumper');
|
||||
$io->comment(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $currentName));
|
||||
$errorIo->title('Translation Messages Extractor and Dumper');
|
||||
$errorIo->comment(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $currentName));
|
||||
|
||||
// load any messages from templates
|
||||
$extractedCatalogue = new MessageCatalogue($input->getArgument('locale'));
|
||||
$io->comment('Parsing templates...');
|
||||
$errorIo->comment('Parsing templates...');
|
||||
$extractor = $this->getContainer()->get('translation.extractor');
|
||||
$extractor->setPrefix($input->getOption('no-prefix') ? '' : $input->getOption('prefix'));
|
||||
foreach ($transPaths as $path) {
|
||||
@ -144,7 +146,7 @@ EOF
|
||||
|
||||
// load any existing messages from the translation files
|
||||
$currentCatalogue = new MessageCatalogue($input->getArgument('locale'));
|
||||
$io->comment('Loading translation files...');
|
||||
$errorIo->comment('Loading translation files...');
|
||||
$loader = $this->getContainer()->get('translation.loader');
|
||||
foreach ($transPaths as $path) {
|
||||
$path .= 'translations';
|
||||
@ -165,7 +167,7 @@ EOF
|
||||
|
||||
// Exit if no messages found.
|
||||
if (!count($operation->getDomains())) {
|
||||
$io->warning('No translation messages were found.');
|
||||
$errorIo->warning('No translation messages were found.');
|
||||
|
||||
return;
|
||||
}
|
||||
@ -199,7 +201,7 @@ EOF
|
||||
}
|
||||
|
||||
if ($input->getOption('output-format') == 'xlf') {
|
||||
$io->comment('Xliff output version is <info>1.2</info>');
|
||||
$errorIo->comment('Xliff output version is <info>1.2</info>');
|
||||
}
|
||||
|
||||
$resultMessage = sprintf('%d message%s successfully extracted', $extractedMessagesCount, $extractedMessagesCount > 1 ? 's were' : ' was');
|
||||
@ -211,7 +213,7 @@ EOF
|
||||
|
||||
// save the files
|
||||
if ($input->getOption('force') === true) {
|
||||
$io->comment('Writing files...');
|
||||
$errorIo->comment('Writing files...');
|
||||
|
||||
$bundleTransPath = false;
|
||||
foreach ($transPaths as $path) {
|
||||
@ -232,7 +234,7 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
$io->success($resultMessage.'.');
|
||||
$errorIo->success($resultMessage.'.');
|
||||
}
|
||||
|
||||
private function filterCatalogue(MessageCatalogue $catalogue, $domain)
|
||||
|
@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
@ -85,8 +86,9 @@ EOF
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
|
||||
|
||||
$input->isInteractive() ? $io->title('Symfony Password Encoder Utility') : $io->newLine();
|
||||
$input->isInteractive() ? $errorIo->title('Symfony Password Encoder Utility') : $errorIo->newLine();
|
||||
|
||||
$password = $input->getArgument('password');
|
||||
$userClass = $input->getArgument('user-class');
|
||||
@ -101,12 +103,12 @@ EOF
|
||||
|
||||
if (!$password) {
|
||||
if (!$input->isInteractive()) {
|
||||
$io->error('The password must not be empty.');
|
||||
$errorIo->error('The password must not be empty.');
|
||||
|
||||
return 1;
|
||||
}
|
||||
$passwordQuestion = $this->createPasswordQuestion();
|
||||
$password = $io->askQuestion($passwordQuestion);
|
||||
$password = $errorIo->askQuestion($passwordQuestion);
|
||||
}
|
||||
|
||||
$salt = null;
|
||||
@ -114,9 +116,9 @@ EOF
|
||||
if ($input->isInteractive() && !$emptySalt) {
|
||||
$emptySalt = true;
|
||||
|
||||
$io->note('The command will take care of generating a salt for you. Be aware that some encoders advise to let them generate their own salt. If you\'re using one of those encoders, please answer \'no\' to the question below. '.PHP_EOL.'Provide the \'empty-salt\' option in order to let the encoder handle the generation itself.');
|
||||
$errorIo->note('The command will take care of generating a salt for you. Be aware that some encoders advise to let them generate their own salt. If you\'re using one of those encoders, please answer \'no\' to the question below. '.PHP_EOL.'Provide the \'empty-salt\' option in order to let the encoder handle the generation itself.');
|
||||
|
||||
if ($io->confirm('Confirm salt generation ?')) {
|
||||
if ($errorIo->confirm('Confirm salt generation ?')) {
|
||||
$salt = $this->generateSalt();
|
||||
$emptySalt = false;
|
||||
}
|
||||
@ -136,12 +138,12 @@ EOF
|
||||
$io->table(array('Key', 'Value'), $rows);
|
||||
|
||||
if (!$emptySalt) {
|
||||
$io->note(sprintf('Make sure that your salt storage field fits the salt length: %s chars', strlen($salt)));
|
||||
$errorIo->note(sprintf('Make sure that your salt storage field fits the salt length: %s chars', strlen($salt)));
|
||||
} elseif ($bcryptWithoutEmptySalt) {
|
||||
$io->note('Bcrypt encoder used: the encoder generated its own built-in salt.');
|
||||
$errorIo->note('Bcrypt encoder used: the encoder generated its own built-in salt.');
|
||||
}
|
||||
|
||||
$io->success('Password encoding succeeded');
|
||||
$errorIo->success('Password encoding succeeded');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user