From 3cbe7cf590e0a490e1ca8042f6c9d5171cceea06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pluchino?= Date: Wed, 18 Jan 2012 12:51:37 +0100 Subject: [PATCH 1/2] Fix bug display in FileDownloader --- src/Composer/Downloader/FileDownloader.php | 4 ++-- src/Composer/IO/ConsoleIO.php | 2 +- src/Composer/IO/IOInterface.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index 8f95d6079..e55c4d09d 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -103,7 +103,7 @@ abstract class FileDownloader implements DownloaderInterface $ctx = stream_context_create($params); stream_context_set_params($ctx, array("notification" => array($this, 'callbackGet'))); - $this->io->overwrite(" Downloading: connection..."); + $this->io->overwrite(" Downloading: connection...", false); copy($url, $fileName, $ctx); $this->io->overwrite(" Downloading"); @@ -193,7 +193,7 @@ abstract class FileDownloader implements DownloaderInterface } if (0 === $progression % 5) { - $this->io->overwrite(" Downloading: $progression%"); + $this->io->overwrite(" Downloading: $progression%", false); } } break; diff --git a/src/Composer/IO/ConsoleIO.php b/src/Composer/IO/ConsoleIO.php index 381cb9b84..707c66579 100644 --- a/src/Composer/IO/ConsoleIO.php +++ b/src/Composer/IO/ConsoleIO.php @@ -65,7 +65,7 @@ class ConsoleIO implements IOInterface /** * {@inheritDoc} */ - public function overwrite($messages, $size = 80, $newline = false) + public function overwrite($messages, $newline = true, $size = 80) { for ($place = $size; $place > 0; $place--) { $this->write("\x08", false); diff --git a/src/Composer/IO/IOInterface.php b/src/Composer/IO/IOInterface.php index 311901529..1b84daab7 100644 --- a/src/Composer/IO/IOInterface.php +++ b/src/Composer/IO/IOInterface.php @@ -38,10 +38,10 @@ interface IOInterface * Overwrites a previous message to the output. * * @param string|array $messages The message as an array of lines or a single string - * @param integer $size The size of line * @param Boolean $newline Whether to add a newline or not + * @param integer $size The size of line */ - function overwrite($messages, $size = 80, $newline = true); + function overwrite($messages, $newline = true, $size = 80); /** * Asks a question to the user. From 76deb2d302a6643cf659d0fb640461b074b255b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pluchino?= Date: Wed, 18 Jan 2012 13:07:49 +0100 Subject: [PATCH 2/2] Fix bug on askAndHideAnswer() (because of the writeln() deletation) --- src/Composer/IO/ConsoleIO.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Composer/IO/ConsoleIO.php b/src/Composer/IO/ConsoleIO.php index 707c66579..fc790194e 100644 --- a/src/Composer/IO/ConsoleIO.php +++ b/src/Composer/IO/ConsoleIO.php @@ -124,16 +124,16 @@ class ConsoleIO implements IOInterface . addslashes($question) . '", ""))'); $command = "cscript //nologo " . escapeshellarg($vbscript); - $this->write($question); + $this->write($question, false); $value = rtrim(shell_exec($command)); unlink($vbscript); for ($i = 0; $i < strlen($value); ++$i) { - $this->write('*'); + $this->write('*', false); } - $this->writeln(''); + $this->write(''); return $value; } @@ -142,22 +142,22 @@ class ConsoleIO implements IOInterface if (rtrim(shell_exec($command)) === 'OK') { $command = "/usr/bin/env bash -c 'echo OK'"; - $this->write($question); + $this->write($question, false); $command = "/usr/bin/env bash -c 'read -s mypassword && echo \$mypassword'"; $value = rtrim(shell_exec($command)); for ($i = 0; $i < strlen($value); ++$i) { - $this->write('*'); + $this->write('*', false); } - $this->writeln(''); + $this->write(''); return $value; } // for other OS without shell_exec (does not hide the answer) - $this->writeln(''); + $this->write(''); return $this->ask($question); }