? 642584_pluggable_auth.patch
? 805966.patch
? 857138.patch
? 874466-deploy-delete-plan-items.patch
? 893828_drush_options-3.patch
? 893828_drush_options.patch
? deploy-805966-4.patch
Index: includes/deploy.drush.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/deploy/includes/Attic/deploy.drush.inc,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 deploy.drush.inc
--- includes/deploy.drush.inc	14 Aug 2010 03:44:22 -0000	1.1.2.1
+++ includes/deploy.drush.inc	5 Sep 2010 20:47:24 -0000
@@ -8,12 +8,28 @@
  * Implementation of hook_drush_command().
  */
 function deploy_drush_command() {
+  // This hook is fired before Drupal is bootstraped long enough to find out
+  // what authentication methods and options that are available. So we must
+  // execute the full bootstrap here.
+  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+
   $items = array();
+  // Fetch all auth types to find out what options they have.
+  $auth_types = deploy_get_auth_types();
+  $auth_options = array();
+  foreach ($auth_types as $auth_type => $auth_info) {
+    $form = deploy_auth_invoke($auth_type, 'form callback');
+    foreach ($form as $option => $control) {
+      $auth_options[$option] = dt("Only when server is using !title.", array('!title' => drupal_strtolower($auth_info['title']))) . ' ' . $control['#description'];
+    }
+  }
   $items['deploy'] = array(
     'description' => 'Executes a deployment plan',
     'options' => array (
-      'show-progress' => 'Will cause progress information to be printed to stdout',
-    ),
+      'plan' => 'The pid of the plan you want to deploy.',
+      'server' => 'The sid of the server you want to deploy to.',
+      'silent' => 'Setting this to any value will suppress the file listing on deployment.',
+    ) + $auth_options,
   );
   return $items;
 }
@@ -33,81 +49,100 @@ function drush_deploy() {
 
   // If there are plans...
   if (!empty($plans)) {
-    
-    // List plans and ask which one to deploy. Save the response in $vars.
+    // If a plan was not specified as an option, then prompt for it.
     foreach ($plans as $plan) {
       $plan_options[$plan['pid']] = $plan['name'];
     }
-    if (!($plan_id = drush_choice($plan_options, dt('Which plan would you like to deploy?')))) {
-      return;
+    if (!$plan_id = drush_get_option('plan')) {
+      // List plans and ask which one to deploy. Save the response in $vars.
+      if (!($plan_id = drush_choice($plan_options, dt('Which plan would you like to deploy?')))) {
+        return;
+      }
     }
     $vars['!plan'] = $plan_options[$plan_id];
-  
-    // List servers and ask which one to deploy to. Save the response in $vars.
+
+    // If a server was not specified as an option, then prompt for it.
     $server_options = deploy_get_servers();
-    if (!$server_id = drush_choice($server_options, dt('Which server would you like to deploy to?'))) {
-      return;
+    if (!$server_id = drush_get_option('server')) {
+      // List servers and ask which one to deploy to. Save the response in $vars.
+      if (!$server_id = drush_choice($server_options, dt('Which server would you like to deploy to?'))) {
+        return;
+      }
     }
     $vars['!server'] = $server_options[$server_id];
-  
-    // Ditto for username and password.
-    $username = drush_prompt(dt('What username would you like to use'), $user->name);
-    $vars['!username'] = $username;
-    $pass = drush_prompt(dt('What password would you like to use for this user'));
-  
-    // Confirm
-    if (drush_confirm(dt('Deploy !plan to !server using user !username', $vars))) {
-      
-      // For anyone looking to work with the Deploy API, this is a pretty 
-      // complete tutorial.
-      
-      // Initialize setup variables
-      deploy_init_deployment($plan_id, $server_id);
-      
-      // Attempt to get a session on the remote server. 
-      if (deploy_set_session($username, $pass)) {
-        $items = deploy_get_plan_items($plan_id);
-        $item_count = count($items);
-        $count = 0;
-  
-        // Run through the items in our plan and run the dependency checking
-        // hooks.
-        foreach ($items as $item) {
-          $count++;
-          deploy_plan_check_item($item['module'], $item['data']);
+
+    // Now we need to fetch the form for the auth type this server uses.
+    // By doing so we know what options to promt the user for.
+    $server = deploy_get_server($server_id);
+    $form = deploy_auth_invoke($server['auth_type'], 'form callback');
+    // This option array will work as $form_state['values'] that is normally
+    // passed to deploy_plan_init().
+    $options = array();
+    foreach ($form as $option => $control) {
+      if (!$value = drush_get_option($option)) {
+        if (!$value = drush_prompt(dt($control['#title'], array('!option' => $option)))) {
+          return;
         }
+      }
+      $options[$option] = $value;
+    }
+
+    if (!drush_confirm(dt('Deploy !plan to !server', $vars))) {
+      return;
+    }
+
+    // For anyone looking to work with the Deploy API, this is a pretty
+    // complete tutorial.
+
+    // Attempt to get a session on the remote server.
+    if (deploy_plan_init($plan_id, $server_id, $options)) {
+      $items = deploy_get_plan_items($plan_id);
+      $item_count = count($items);
+      $count = 0;
+
+      // Run through the items in our plan and run the dependency checking
+      // hooks.
+      foreach ($items as $item) {
+        $count++;
+        deploy_plan_check_item($item['module'], $item['data']);
+      }
+
+      // If silent is not specified then report number of items to be pushed.
+      if (!drush_get_option('silent')) {
         drush_log(dt('!count items checked', array('!count' => $count)), 'ok', FALSE);
-        
-        // Run the post-check cleanup routines.
-        module_invoke_all('deploy_check_cleanup', $plan_id);
-  
-        // The plan items can change (and almost certainly have 
-        // changed) as a result of plan cleanup, so get the list again.
-        $items = deploy_get_plan_items($plan_id);
-        $item_count = count($items);
-        $count = 0;
-
-        // Go through this list and deploy each item one by one.
-        foreach ($items as $item) {
-          $count++;
+      }
+
+      // Run the post-check cleanup routines.
+      module_invoke_all('deploy_check_cleanup', $plan_id);
+
+      // The plan items can change (and almost certainly have
+      // changed) as a result of plan cleanup, so get the list again.
+      $items = deploy_get_plan_items($plan_id);
+      $item_count = count($items);
+      $count = 0;
+
+      // Go through this list and deploy each item one by one.
+      foreach ($items as $item) {
+        $count++;
+        if (!drush_get_option('silent')) {
           drush_log(dt('Deploying item: !item', array('!item' => $item['description'])), 'ok', FALSE);
-          deploy_item($item);
         }
-        $deploy_log_id = variable_get('deploy_log_id', NULL);
+        deploy_item($item);
+      }
+      $deploy_log_id = variable_get('deploy_log_id', NULL);
 
-        // Run the post-deployment cleanup routines. 
-        deploy_plan_cleanup();
+      // Run the post-deployment cleanup routines.
+      deploy_plan_cleanup();
 
-        // Hey look we're done.
-        // @todo: make this report a link to the log details for the lazy.
-        drush_log(dt('Deployment completed, check deployment log !log_id for results'), array('!log_id' => $deploy_log_id), 'ok', FALSE);
-      }
-      else {
-        drush_log(dt('Failure setting up deploy session'), 'error', TRUE);
-      }
+      // Hey look we're done.
+      // @todo: make this report a link to the log details for the lazy.
+      drush_log(dt('Deployment completed, check deployment log !log_id for results'), array('!log_id' => $deploy_log_id), 'ok', FALSE);
+    }
+    else {
+      drush_log(dt('Failure setting up deploy session'), 'error', TRUE);
     }
   }
   else {
     drush_print(dt('There are no plans to deploy'));
   }
-}
\ No newline at end of file
+}
