Move password interaction to interact function

This commit is contained in:
Bart Visscher 2014-02-17 18:09:42 +01:00
parent bcb78e48b2
commit 8a6dcdf4a4
1 changed files with 14 additions and 12 deletions

View File

@ -29,6 +29,19 @@ class ConvertType extends Command {
parent::__construct(); parent::__construct();
} }
protected function interact(InputInterface $input, OutputInterface $output) {
parent::interact($input, $output);
if (!$input->getOption('password')) {
$dialog = $this->getHelperSet()->get('dialog');
$password = $dialog->askHiddenResponse(
$output,
'What is the database password?',
false
);
$input->setOption('password', $password);
}
}
protected function configure() { protected function configure() {
$this $this
->setName('db:convert-type') ->setName('db:convert-type')
@ -137,22 +150,11 @@ class ConvertType extends Command {
$username = $input->getArgument('username'); $username = $input->getArgument('username');
$hostname = $input->getArgument('hostname'); $hostname = $input->getArgument('hostname');
$dbname = $input->getArgument('database'); $dbname = $input->getArgument('database');
$password = $input->getOption('password');
if (!isset(self::$type2driver[$type])) { if (!isset(self::$type2driver[$type])) {
throw new InvalidArgumentException('Unknown type: '.$type); throw new InvalidArgumentException('Unknown type: '.$type);
} }
if ($input->getOption('password')) {
$password = $input->getOption('password');
} else {
// TODO: should be moved to the interact function
$dialog = $this->getHelperSet()->get('dialog');
$password = $dialog->askHiddenResponse(
$output,
'What is the database password?',
false
);
$input->setOption('password', $password);
}
$connectionParams = array( $connectionParams = array(
'driver' => self::$type2driver[$type], 'driver' => self::$type2driver[$type],
'user' => $username, 'user' => $username,