diff --git a/commands/core/core.drush.inc b/commands/core/core.drush.inc index ed6c98d..e6dfc30 100644 --- a/commands/core/core.drush.inc +++ b/commands/core/core.drush.inc @@ -94,6 +94,11 @@ function core_drush_command() { ), 'topics' => array('docs-readme'), ); + $items['core-quick-drupal'] = array( + 'description' => 'Download, install, serve and login to Drupal with minimal configuration and dependencies.', + 'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, + 'aliases' => array('qd'), + ); $items['php-eval'] = array( 'description' => 'Evaluate arbitrary php code after bootstrapping Drupal (if available).', 'examples' => array( @@ -624,6 +629,36 @@ function _drush_core_is_named_in_array($key, $the_array) { } /** + * Command callback. + */ +function drush_core_quick_drupal($name) { + $base = getcwd() . '/' . $name; + drush_set_option('destination', $name); + drush_set_option('drupal-project-rename', 'drupal'); + drush_invoke('pm-download', 'drupal'); + drush_set_option('root', $base . '/drupal'); + drush_set_option('uri', 'http://localhost:8888'); + drush_set_option('db-url', 'sqlite:' . $base . '/' . $name . '.sqlite'); + drush_bootstrap_max(DRUSH_BOOTSTRAP_DRUPAL_ROOT); + drush_invoke('site-install'); + drush_bootstrap_max(); + $user = user_load(1); + $login = user_pass_reset_url($user); + drush_print(dt('Login URL: ') . $login); + // See if we can find an OS helper to open in default browser + if (drush_shell_exec('which sensible-browser')) { + $browser = 'sensible-browser'; + } + else if (drush_shell_exec('which open')) { + $browser = 'open'; + } + // This is a race, although the server always comes up in time on my machine + // would be worth thinking of another way to do this. + drush_shell_exec($browser . ' %s', $login); + drush_invoke('runserver'); +} + +/** * Command callback. Runs "naked" php scripts * and drush "shebang" scripts ("#!/usr/bin/env drush"). */