Download & Extend

coder-upgrade drush command

Project:Coder
Version:7.x-1.x-dev
Component:Coder Upgrade
Category:feature request
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community

Issue Summary

i am using coder_upgrade via drush through this mechanism.

created code_upgrade.drush.inc

<?php
<?php

function coder_upgrade_drush_command() {
  return array(
   
'coder-upgrade' => array(),
  );
}

function
drush_coder_upgrade($name) {
 
$form_state = array();
 
$form_state['values']['extensions']['list']['module'] =  'module';
 
$form_state['values']['extensions']['list']['inc'] =  'inc';
 
$form_state['values']['extensions']['list']['info'] =  'info';
 
$form_state['values']['extensions']['list']['install'] =  'install';

 
$form_state['values']['upgrades']['list']['coder_upgrade'] =  'coder_upgrade';
 
$form_state['values']['directories']['list'][$name] =  $name;

 
drupal_form_submit('coder_upgrade_conversions_form', $form_state);
}
?>

I also added calls to drush_log in the parser and upgrade logging functions.

<?php
if (function_exists('drush_log')) {
 
drush_log($text);
}
?>

this works for me (tm) , and is enough to get going.
very little polish could finish it off.

I am actually puzzled as to why coder_upgrade depends on drupal at all. It only uses drupal_alter, and even that can be worked around. It's reliance on forms is also annoying.

Comments

#1

Status:needs work» needs review

needs to be in coder_upgrade.drush.inc

<?php
/**
* Implements hook_drush_help().
*/
function coder_upgrade_drush_help($command) {
  switch (
$command) {
    case
'crush:coder-upgrade':
      return
dt('Upgrade a module in the automated manner');
  }
}

/**
* Implements hook_drush_command().
*/
function coder_upgrade_drush_command() {
 
$items = array();
 
$items['coder-upgrade'] = array(
   
'description' => dt('Upgrade a module via automated porting methods'),
   
'arguments'   => array(
     
'arg1'    => dt('token'),
    ),
   
'examples' => array(
     
'Standard example' => 'drush coder-upgrade token',
    ),
   
'aliases' => array('cup'),
  );
  return
$items;
}

/**
* Callback for drush upgrade function.
*/
function drush_coder_upgrade($name) {
 
module_load_include('inc', 'coder_upgrade', 'includes/conversion');
 
$form_state = array();
 
$form_state['values']['extensions']['list']['module'] =  'module';
 
$form_state['values']['extensions']['list']['inc'] =  'inc';
 
$form_state['values']['extensions']['list']['info'] =  'info';
 
$form_state['values']['extensions']['list']['install'] =  'install';

 
$form_state['values']['upgrades']['list']['coder_upgrade'] =  'coder_upgrade';
 
$form_state['values']['directories']['list'][$name] =  $name;

 
drupal_form_submit('coder_upgrade_conversions_form', $form_state);
}
?>

#2

rolling a proper patch with tweaks to allow for multiple files to be upgraded at the same time; shortcut command is cup

AttachmentSize
coder_upgrade-drush_support-780034.patch 2.05 KB

#3

Status:needs review» reviewed & tested by the community

Patch and go, works for me...timesaver.

#4

This is great -- I was actually able to figure out why coder_upgrade was giving me a WSOD when upgrading Highslide.

nobody click here