diff --git a/commands/core/core.drush.inc b/commands/core/core.drush.inc index 45b6d00..25710be 100644 --- a/commands/core/core.drush.inc +++ b/commands/core/core.drush.inc @@ -97,6 +97,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( @@ -629,6 +634,44 @@ function _drush_core_is_named_in_array($key, $the_array) { } /** + * Validate callback for core-quick-drupal command. + */ +function drush_core_quick_drupal_validate($name) { + // TODO: Add validation for each part. +} + +/** + * Callback for core-quick-drupal command. + */ +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_to_phase(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 URLs in default browser + if (drush_shell_exec('which xdg-open')) { + $browser = 'xdg-open'; + } + else if (drush_shell_exec('which open')) { + $browser = 'open'; + } + if (isset($browser)) { + $pipes = array(); + proc_close(proc_open('COUNT=1; SERVERUP=1; while [ "$COUNT" -le "20" -a "$SERVERUP" -ne "0" ]; do COUNT=$(($COUNT+1)); echo "Waiting for server to start...$COUNT"; sleep 1; curl -Is ' . $login . ' > /dev/null; SERVERUP=$?; done && ' . $browser . ' ' . $login . ' &', array(), $pipes)); + } + drush_invoke('runserver'); +} + +/** * Command callback. Runs "naked" php scripts * and drush "shebang" scripts ("#!/usr/bin/env drush"). */