Author: fabien
Date: 2010-01-14 16:02:22 +0100 (Thu, 14 Jan 2010)
New Revision: 26635
Modified:
branches/2.0/src/Symfony/Components/Console/Application.php
branches/2.0/src/Symfony/Components/Console/Command/HelpCommand.php
branches/2.0/src/Symfony/Components/Console/Command/ListCommand.php
branches/2.0/src/Symfony/Components/Console/Helper/DialogHelper.php
branches/2.0/src/Symfony/Components/Console/Output/NullOutput.php
branches/2.0/src/Symfony/Components/Console/Output/Output.php
branches/2.0/src/Symfony/Components/Console/Output/StreamOutput.php
branches/2.0/src/Symfony/Components/Console/Shell.php
branches/2.0/tests/fixtures/Symfony/Components/Console/FooCommand.php
branches/2.0/tests/fixtures/Symfony/Components/Console/TestCommand.php
branches/2.0/tests/unit/Symfony/Components/Console/Command/CommandTest.php
branches/2.0/tests/unit/Symfony/Components/Console/Output/OutputTest.php
branches/2.0/tests/unit/Symfony/Components/Console/Output/StreamOutputTest.php
branches/2.0/tests/unit/Symfony/Components/Console/Tester/ApplicationTesterTest.php
branches/2.0/tests/unit/Symfony/Components/Console/Tester/CommandTesterTest.php
Log:
Merge branch 'master' of git://github.com/symfony/symfony
Modified: branches/2.0/src/Symfony/Components/Console/Application.php
===================================================================
--- branches/2.0/src/Symfony/Components/Console/Application.php 2010-01-14
15:01:17 UTC (rev 26634)
+++ branches/2.0/src/Symfony/Components/Console/Application.php 2010-01-14
15:02:22 UTC (rev 26635)
@@ -187,7 +187,7 @@
if (true === $input->hasParameterOption(array('--version', '-V')))
{
- $output->write($this->getLongVersion());
+ $output->writeln($this->getLongVersion());
return 0;
}
@@ -732,22 +732,22 @@
$messages[] = str_repeat(' ', $len);
- $output->write("\n");
+ $output->writeln("\n");
foreach ($messages as $message)
{
- $output->write("<error>$message</error>");
+ $output->writeln("<error>$message</error>");
}
- $output->write("\n");
+ $output->writeln("\n");
if (null !== $this->runningCommand)
{
- $output->write(sprintf('<info>%s</info>',
sprintf($this->runningCommand->getSynopsis(), $this->getName())));
- $output->write("\n");
+ $output->writeln(sprintf('<info>%s</info>',
sprintf($this->runningCommand->getSynopsis(), $this->getName())));
+ $output->writeln("\n");
}
if (Output::VERBOSITY_VERBOSE === $output->getVerbosity())
{
- $output->write('</comment>Exception trace:</comment>');
+ $output->writeln('</comment>Exception trace:</comment>');
// exception related properties
$trace = $e->getTrace();
@@ -766,10 +766,10 @@
$file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
$line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
- $output->write(sprintf(' %s%s%s() at <info>%s:%s</info>', $class,
$type, $function, $file, $line));
+ $output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class,
$type, $function, $file, $line));
}
- $output->write("\n");
+ $output->writeln("\n");
}
}
Modified: branches/2.0/src/Symfony/Components/Console/Command/HelpCommand.php
===================================================================
--- branches/2.0/src/Symfony/Components/Console/Command/HelpCommand.php
2010-01-14 15:01:17 UTC (rev 26634)
+++ branches/2.0/src/Symfony/Components/Console/Command/HelpCommand.php
2010-01-14 15:02:22 UTC (rev 26635)
@@ -72,11 +72,11 @@
if ($input->getOption('xml'))
{
- $output->write($this->command->asXml(), Output::OUTPUT_RAW);
+ $output->writeln($this->command->asXml(), Output::OUTPUT_RAW);
}
else
{
- $output->write($this->command->asText());
+ $output->writeln($this->command->asText());
}
}
}
Modified: branches/2.0/src/Symfony/Components/Console/Command/ListCommand.php
===================================================================
--- branches/2.0/src/Symfony/Components/Console/Command/ListCommand.php
2010-01-14 15:01:17 UTC (rev 26634)
+++ branches/2.0/src/Symfony/Components/Console/Command/ListCommand.php
2010-01-14 15:02:22 UTC (rev 26635)
@@ -62,11 +62,11 @@
{
if ($input->getOption('xml'))
{
-
$output->write($this->application->asXml($input->getArgument('namespace')),
Output::OUTPUT_RAW);
+
$output->writeln($this->application->asXml($input->getArgument('namespace')),
Output::OUTPUT_RAW);
}
else
{
-
$output->write($this->application->asText($input->getArgument('namespace')));
+
$output->writeln($this->application->asText($input->getArgument('namespace')));
}
}
}
Modified: branches/2.0/src/Symfony/Components/Console/Helper/DialogHelper.php
===================================================================
--- branches/2.0/src/Symfony/Components/Console/Helper/DialogHelper.php
2010-01-14 15:01:17 UTC (rev 26634)
+++ branches/2.0/src/Symfony/Components/Console/Helper/DialogHelper.php
2010-01-14 15:02:22 UTC (rev 26635)
@@ -34,7 +34,7 @@
public function ask(OutputInterface $output, $question, $default = null)
{
// @codeCoverageIgnoreStart
- $output->write($question);
+ $output->writeln($question);
$ret = trim(fgets(STDIN));
@@ -91,7 +91,7 @@
{
if (null !== $error)
{
-
$output->write($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(),
'error'));
+
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(),
'error'));
}
$value = $this->ask($output, $question, null);
Modified: branches/2.0/src/Symfony/Components/Console/Output/NullOutput.php
===================================================================
--- branches/2.0/src/Symfony/Components/Console/Output/NullOutput.php
2010-01-14 15:01:17 UTC (rev 26634)
+++ branches/2.0/src/Symfony/Components/Console/Output/NullOutput.php
2010-01-14 15:02:22 UTC (rev 26635)
@@ -26,8 +26,9 @@
* Writes a message to the output.
*
* @param string $message A message to write to the output
+ * @param Boolean $newline Whether to add a newline or not
*/
- public function doWrite($message)
+ public function doWrite($message, $newline)
{
}
}
Modified: branches/2.0/src/Symfony/Components/Console/Output/Output.php
===================================================================
--- branches/2.0/src/Symfony/Components/Console/Output/Output.php
2010-01-14 15:01:17 UTC (rev 26634)
+++ branches/2.0/src/Symfony/Components/Console/Output/Output.php
2010-01-14 15:02:22 UTC (rev 26635)
@@ -111,12 +111,24 @@
}
/**
+ * Writes a message to the output and adds a newline at the end.
+ *
+ * @param string|array $messages The message as an array of lines of a
single string
+ * @param integer $type The type of output
+ */
+ public function writeln($messages, $type = 0)
+ {
+ $this->write($messages, true, $type);
+ }
+
+ /**
* Writes a message to the output.
*
* @param string|array $messages The message as an array of lines of a
single string
+ * @param Boolean $newline Whether to add a newline or not
* @param integer $type The type of output
*/
- public function write($messages, $type = 0)
+ public function write($messages, $newline = false, $type = 0)
{
if (self::VERBOSITY_QUIET === $this->verbosity)
{
@@ -144,16 +156,17 @@
throw new \InvalidArgumentException(sprintf('Unknown output type
given (%s)', $type));
}
- $this->doWrite($message);
+ $this->doWrite($message, $newline);
}
}
/**
* Writes a message to the output.
*
- * @param string $message A message to write to the output
+ * @param string $message A message to write to the output
+ * @param Boolean $newline Whether to add a newline or not
*/
- abstract public function doWrite($message);
+ abstract public function doWrite($message, $newline);
/**
* Formats a message according to the given styles.
Modified: branches/2.0/src/Symfony/Components/Console/Output/StreamOutput.php
===================================================================
--- branches/2.0/src/Symfony/Components/Console/Output/StreamOutput.php
2010-01-14 15:01:17 UTC (rev 26634)
+++ branches/2.0/src/Symfony/Components/Console/Output/StreamOutput.php
2010-01-14 15:02:22 UTC (rev 26635)
@@ -67,11 +67,12 @@
/**
* Writes a message to the output.
*
- * @param string $message A message to write to the output
+ * @param string $message A message to write to the output
+ * @param Boolean $newline Whether to add a newline or not
*/
- public function doWrite($message)
+ public function doWrite($message, $newline)
{
- if (false === @fwrite($this->stream, $message.PHP_EOL))
+ if (false === @fwrite($this->stream, $message.($newline ? PHP_EOL : '')))
{
// @codeCoverageIgnoreStart
// should never happen
Modified: branches/2.0/src/Symfony/Components/Console/Shell.php
===================================================================
--- branches/2.0/src/Symfony/Components/Console/Shell.php 2010-01-14
15:01:17 UTC (rev 26634)
+++ branches/2.0/src/Symfony/Components/Console/Shell.php 2010-01-14
15:02:22 UTC (rev 26635)
@@ -62,14 +62,14 @@
readline_read_history($this->history);
readline_completion_function(array($this, 'autocompleter'));
- $this->output->write($this->getHeader());
+ $this->output->writeln($this->getHeader());
while (true)
{
$command = readline($this->application->getName().' > ');
if (false === $command)
{
- $this->output->write("\n");
+ $this->output->writeln("\n");
break;
}
@@ -79,7 +79,7 @@
if (0 !== $ret = $this->application->run(new StringInput($command),
$this->output))
{
- $this->output->write(sprintf('<error>The command terminated with an
error status (%s)</error>', $ret));
+ $this->output->writeln(sprintf('<error>The command terminated with an
error status (%s)</error>', $ret));
}
}
}
Modified: branches/2.0/tests/fixtures/Symfony/Components/Console/FooCommand.php
===================================================================
--- branches/2.0/tests/fixtures/Symfony/Components/Console/FooCommand.php
2010-01-14 15:01:17 UTC (rev 26634)
+++ branches/2.0/tests/fixtures/Symfony/Components/Console/FooCommand.php
2010-01-14 15:02:22 UTC (rev 26635)
@@ -20,7 +20,7 @@
protected function interact(InputInterface $input, OutputInterface $output)
{
- $output->write('interact called');
+ $output->writeln('interact called');
}
protected function execute(InputInterface $input, OutputInterface $output)
@@ -28,6 +28,6 @@
$this->input = $input;
$this->output = $output;
- $output->write('called');
+ $output->writeln('called');
}
}
Modified: branches/2.0/tests/fixtures/Symfony/Components/Console/TestCommand.php
===================================================================
--- branches/2.0/tests/fixtures/Symfony/Components/Console/TestCommand.php
2010-01-14 15:01:17 UTC (rev 26634)
+++ branches/2.0/tests/fixtures/Symfony/Components/Console/TestCommand.php
2010-01-14 15:02:22 UTC (rev 26635)
@@ -28,11 +28,11 @@
protected function execute(InputInterface $input, OutputInterface $output)
{
- $output->write('execute called');
+ $output->writeln('execute called');
}
protected function interact(InputInterface $input, OutputInterface $output)
{
- $output->write('interact called');
+ $output->writeln('interact called');
}
}
Modified:
branches/2.0/tests/unit/Symfony/Components/Console/Command/CommandTest.php
===================================================================
--- branches/2.0/tests/unit/Symfony/Components/Console/Command/CommandTest.php
2010-01-14 15:01:17 UTC (rev 26634)
+++ branches/2.0/tests/unit/Symfony/Components/Console/Command/CommandTest.php
2010-01-14 15:02:22 UTC (rev 26635)
@@ -190,7 +190,7 @@
$command->setApplication($application);
$ret = $command->setCode(function (InputInterface $input, OutputInterface
$output)
{
- $output->write('from the code...');
+ $output->writeln('from the code...');
});
$t->is($ret, $command, '->setCode() implements a fluent interface');
$tester = new CommandTester($command);
Modified:
branches/2.0/tests/unit/Symfony/Components/Console/Output/OutputTest.php
===================================================================
--- branches/2.0/tests/unit/Symfony/Components/Console/Output/OutputTest.php
2010-01-14 15:01:17 UTC (rev 26634)
+++ branches/2.0/tests/unit/Symfony/Components/Console/Output/OutputTest.php
2010-01-14 15:02:22 UTC (rev 26635)
@@ -23,9 +23,9 @@
return static::$styles[$name];
}
- public function doWrite($message)
+ public function doWrite($message, $newline)
{
- $this->output .= $message."\n";
+ $this->output .= $message.($newline ? "\n" : '');
}
}
@@ -51,50 +51,50 @@
Output::setStyle('FOO', array('bg' => 'red', 'fg' => 'yellow', 'blink' =>
true));
$t->is(TestOutput::getStyle('foo'), array('bg' => 'red', 'fg' => 'yellow',
'blink' => true), '::setStyle() sets a new style');
-// ->write()
-$t->diag('->write()');
+// ->writeln()
+$t->diag('->writeln()');
$output = new TestOutput(Output::VERBOSITY_QUIET);
-$output->write('foo');
-$t->is($output->output, '', '->write() outputs nothing if verbosity is set to
VERBOSITY_QUIET');
+$output->writeln('foo');
+$t->is($output->output, '', '->writeln() outputs nothing if verbosity is set
to VERBOSITY_QUIET');
$output = new TestOutput();
-$output->write(array('foo', 'bar'));
-$t->is($output->output, "foo\nbar\n", '->write() can take an array of messages
to output');
+$output->writeln(array('foo', 'bar'));
+$t->is($output->output, "foo\nbar\n", '->writeln() can take an array of
messages to output');
$output = new TestOutput();
-$output->write('<info>foo</info>', Output::OUTPUT_RAW);
-$t->is($output->output, "<info>foo</info>\n", '->write() outputs the raw
message if OUTPUT_RAW is specified');
+$output->writeln('<info>foo</info>', Output::OUTPUT_RAW);
+$t->is($output->output, "<info>foo</info>\n", '->writeln() outputs the raw
message if OUTPUT_RAW is specified');
$output = new TestOutput();
-$output->write('<info>foo</info>', Output::OUTPUT_PLAIN);
-$t->is($output->output, "foo\n", '->write() strips decoration tags if
OUTPUT_PLAIN is specified');
+$output->writeln('<info>foo</info>', Output::OUTPUT_PLAIN);
+$t->is($output->output, "foo\n", '->writeln() strips decoration tags if
OUTPUT_PLAIN is specified');
$output = new TestOutput();
$output->setDecorated(false);
-$output->write('<info>foo</info>');
-$t->is($output->output, "foo\n", '->write() strips decoration tags if
decoration is set to false');
+$output->writeln('<info>foo</info>');
+$t->is($output->output, "foo\n", '->writeln() strips decoration tags if
decoration is set to false');
$output = new TestOutput();
$output->setDecorated(true);
-$output->write('<foo>foo</foo>');
-$t->is($output->output, "\033[33;41;5mfoo\033[0m\n", '->write() decorates the
output');
+$output->writeln('<foo>foo</foo>');
+$t->is($output->output, "\033[33;41;5mfoo\033[0m\n", '->writeln() decorates
the output');
try
{
- $output->write('<foo>foo</foo>', 24);
- $t->fail('->write() throws an \InvalidArgumentException when the type does
not exist');
+ $output->writeln('<foo>foo</foo>', 24);
+ $t->fail('->writeln() throws an \InvalidArgumentException when the type does
not exist');
}
catch (\InvalidArgumentException $e)
{
- $t->pass('->write() throws an \InvalidArgumentException when the type does
not exist');
+ $t->pass('->writeln() throws an \InvalidArgumentException when the type does
not exist');
}
try
{
- $output->write('<bar>foo</bar>');
- $t->fail('->write() throws an \InvalidArgumentException when a style does
not exist');
+ $output->writeln('<bar>foo</bar>');
+ $t->fail('->writeln() throws an \InvalidArgumentException when a style does
not exist');
}
catch (\InvalidArgumentException $e)
{
- $t->pass('->write() throws an \InvalidArgumentException when a style does
not exist');
+ $t->pass('->writeln() throws an \InvalidArgumentException when a style does
not exist');
}
Modified:
branches/2.0/tests/unit/Symfony/Components/Console/Output/StreamOutputTest.php
===================================================================
---
branches/2.0/tests/unit/Symfony/Components/Console/Output/StreamOutputTest.php
2010-01-14 15:01:17 UTC (rev 26634)
+++
branches/2.0/tests/unit/Symfony/Components/Console/Output/StreamOutputTest.php
2010-01-14 15:02:22 UTC (rev 26635)
@@ -42,6 +42,6 @@
// ->doWrite()
$t->diag('->doWrite()');
$output = new StreamOutput($stream);
-$output->write('foo');
+$output->writeln('foo');
rewind($output->getStream());
$t->is(stream_get_contents($output->getStream()), "foo\n", '->doWrite() writes
to the stream');
Modified:
branches/2.0/tests/unit/Symfony/Components/Console/Tester/ApplicationTesterTest.php
===================================================================
---
branches/2.0/tests/unit/Symfony/Components/Console/Tester/ApplicationTesterTest.php
2010-01-14 15:01:17 UTC (rev 26634)
+++
branches/2.0/tests/unit/Symfony/Components/Console/Tester/ApplicationTesterTest.php
2010-01-14 15:02:22 UTC (rev 26635)
@@ -21,7 +21,7 @@
$application->register('foo')
->addArgument('command')
->addArgument('foo')
- ->setCode(function ($input, $output) { $output->write('foo'); })
+ ->setCode(function ($input, $output) { $output->writeln('foo'); })
;
$tester = new ApplicationTester($application);
Modified:
branches/2.0/tests/unit/Symfony/Components/Console/Tester/CommandTesterTest.php
===================================================================
---
branches/2.0/tests/unit/Symfony/Components/Console/Tester/CommandTesterTest.php
2010-01-14 15:01:17 UTC (rev 26634)
+++
branches/2.0/tests/unit/Symfony/Components/Console/Tester/CommandTesterTest.php
2010-01-14 15:02:22 UTC (rev 26635)
@@ -19,7 +19,7 @@
$command = new Command('foo');
$command->addArgument('command');
$command->addArgument('foo');
-$command->setCode(function ($input, $output) { $output->write('foo'); });
+$command->setCode(function ($input, $output) { $output->writeln('foo'); });
$tester = new CommandTester($command);
$tester->execute(array('foo' => 'bar'), array('interactive' => false,
'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE));
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.