Skip to content

Commit

Permalink
Issue #2484: Give site-install and interactive mode.
Browse files Browse the repository at this point in the history
Issue #2484: Give site-install and interactive mode.

Issue #2484: Give site-install and interactive mode.
  • Loading branch information
serundeputy committed Feb 12, 2017
1 parent b23f454 commit 0a0c5a8
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions lib/Drush/Commands/core/SiteInstallCommands.php
Expand Up @@ -190,10 +190,29 @@ public function validate(CommandData $commandData) {
throw new \Exception('The config source is not a directory.');
}
}
if ($commandData->input()->getOption('db-url') == '') {
// Prompt for the db-url data if it was not provided via --db-url.
$database = drush_prompt('Database name');
$driver = drush_prompt('Database driver', 'mysql');
$username = drush_prompt('Database username');
$password = drush_prompt('Database password');
$host = drush_prompt('Database host', 'localhost');
$port = drush_prompt('Database port', '3306');
$db_url = "$driver://$username:$password@$host/$database";

$sql = SqlBase::create($commandData->input()->getOptions());
if (!$sql->getDbSpec()) {
throw new \Exception(dt('Could not determine database connection parameters. Pass --db-url option.'));
$commandData->input()->setOption('db-url', $db_url);

$sql = SqlBase::create($commandData->input()->getOptions());

if (!$sql->getDbSpec()) {
throw new \Exception(dt('Could not determine database connection parameters. Pass --db-url option.'));
}
}
else {
$sql = SqlBase::create($commandData->input()->getOptions());
if (!$sql->getDbSpec()) {
throw new \Exception(dt('Could not determine database connection parameters. Pass --db-url option.'));
}
}
}

Expand All @@ -206,7 +225,6 @@ public function validate(CommandData $commandData) {
public function pre(CommandData $commandData) {
$sql = SqlBase::create($commandData->input()->getOptions());
$db_spec = $sql->getDbSpec();

// Make sure URI is set so we get back a proper $alias_record. Needed for quick-drupal.
_drush_bootstrap_selected_uri();

Expand Down Expand Up @@ -271,4 +289,4 @@ public function pre(CommandData $commandData) {
throw new \Exception(dt('Failed to create database: @error', array('@error' => implode(drush_shell_exec_output()))));
}
}
}
}

0 comments on commit 0a0c5a8

Please sign in to comment.