1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-10 17:12:51 +00:00

Cleanups of IOInterface

This commit is contained in:
Jordi Boggiano 2012-01-17 23:07:33 +01:00
parent edf948454b
commit 434c9ecdeb
7 changed files with 92 additions and 156 deletions

View file

@ -18,10 +18,10 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Helper\HelperSet;
/**
* The Input/Output helper.
*
* @author François Pluchino <francois.pluchino@opendisplay.com>
/**
* The Input/Output helper.
*
* @author François Pluchino <francois.pluchino@opendisplay.com>
*/
class ConsoleIO implements IOInterface
{
@ -57,17 +57,9 @@ class ConsoleIO implements IOInterface
/**
* {@inheritDoc}
*/
public function write($messages, $newline = false, $type = 0)
public function write($messages, $newline = true)
{
$this->output->write($messages, $newline, $type);
}
/**
* {@inheritDoc}
*/
public function writeln($messages, $type = 0)
{
$this->output->writeln($messages, $type);
$this->output->write($messages, $newline);
}
/**
@ -95,62 +87,6 @@ class ConsoleIO implements IOInterface
}
}
/**
* {@inheritDoc}
*/
public function overwriteln($messages, $size = 80, $type = 0)
{
$this->overwrite($messages, $size, true, $type);
}
/**
* {@inheritDoc}
*/
public function setVerbosity($level)
{
$this->output->setVerbosity($level);
}
/**
* {@inheritDoc}
*/
public function getVerbosity()
{
return $this->output->getVerbosity();
}
/**
* {@inheritDoc}
*/
public function setDecorated($decorated)
{
$this->output->setDecorated($decorated);
}
/**
* {@inheritDoc}
*/
public function isDecorated()
{
return $this->output->isDecorated();
}
/**
* {@inheritDoc}
*/
public function setFormatter(OutputFormatterInterface $formatter)
{
$this->output->setFormatter($formatter);
}
/**
* {@inheritDoc}
*/
public function getFormatter()
{
return $this->output->getFormatter();
}
/**
* {@inheritDoc}
*/
@ -167,6 +103,9 @@ class ConsoleIO implements IOInterface
return $this->helperSet->get('dialog')->askConfirmation($this->output, $question, $default);
}
/**
* {@inheritDoc}
*/
public function askAndValidate($question, $validator, $attempts = false, $default = null)
{
return $this->helperSet->get('dialog')->askAndValidate($this->output, $question, $validator, $attempts, $default);
@ -201,19 +140,19 @@ class ConsoleIO implements IOInterface
// for other OS with shell_exec (hide the answer)
if (rtrim(shell_exec($command)) === 'OK') {
$command = "/usr/bin/env bash -c 'echo OK'";
$this->write($question);
$command = "/usr/bin/env bash -c 'read -s mypassword && echo \$mypassword'";
$command = "/usr/bin/env bash -c 'echo OK'";
$this->write($question);
$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->writeln('');
$this->writeln('');
return $value;
}