Skip to content

Commit ef62f5c

Browse files
serundeputymikeker
authored andcommitted
site-install interactive
1 parent 465fac2 commit ef62f5c

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

lib/Drush/Commands/core/SiteInstallCommands.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class SiteInstallCommands extends DrushCommands {
1313
* Install Drupal along with modules/themes/configuration using the specified install profile.
1414
*
1515
* @command site-install
16-
* @param string $profile The install profile you wish to run. Defaults to 'default' in D6, 'standard' in D7+, unless an install profile is marked as exclusive (or as a distribution in D8+ terminology) in which case that is used.
16+
* @param $profile The install profile you wish to run. Defaults to 'default' in D6, 'standard' in D7+, unless an install profile is marked as exclusive (or as a distribution in D8+ terminology) in which case that is used.
1717
* @param $additional Any additional settings you wish to pass to the profile. The key is in the form [form name].[parameter name]
18-
* @option db-url A Drupal 6 style database URL. Only required for initial install - not re-install.
18+
* @option db-url A Drupal 6 style database URL. Only required for initial install - not re-install. If omitted and required, Drush prompts for this item.
1919
* @option db-prefix An optional table prefix to use for initial install. Can be a key-value array of tables/prefixes in a drushrc file (not the command line).
2020
* @option db-su Account to use when creating a new database. Must have Grant permission (mysql only). Optional.
2121
* @option db-su-pw Password for the "db-su" account. Optional.
@@ -170,9 +170,32 @@ public function validate(CommandData $commandData) {
170170
}
171171

172172
drush_bootstrap_max(DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION);
173-
$sql = SqlBase::create($commandData->input()->getOptions());
173+
try {
174+
$sql = SqlBase::create($commandData->input()->getOptions());
175+
}
176+
catch (\Exception $e) {
177+
// Ask questions to get our data.
178+
if ($commandData->input()->getOption('db-url') == '') {
179+
// Prompt for the db-url data if it was not provided via --db-url.
180+
$database = drush_prompt('Database name');
181+
$driver = drush_prompt('Database driver', 'mysql');
182+
$username = drush_prompt('Database username', 'root');
183+
$password = drush_prompt('Database password', '', FALSE);
184+
$host = drush_prompt('Database host', '127.0.0.1');
185+
$port = drush_prompt('Database port', '3306');
186+
$db_url = "$driver://$username:$password@$host:$port/$database";
187+
$commandData->input()->setOption('db-url', $db_url);
188+
189+
try {
190+
$sql = SqlBase::create($commandData->input()->getOptions());
191+
}
192+
catch (\Exception $e) {
193+
throw new \Exception(dt('Could not determine database connection parameters. Pass --db-url option.'));
194+
}
195+
}
196+
}
174197
if (!$sql->getDbSpec()) {
175-
throw new \Exception(dt('Could not determine database connection parameters. Pass --db-url option.'));
198+
176199
}
177200
}
178201

0 commit comments

Comments
 (0)