i am using coder_upgrade via drush through this mechanism.

created code_upgrade.drush.inc

<?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.

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.

CommentFileSizeAuthor
#2 coder_upgrade-drush_support-780034.patch2.05 KBbtopro

Comments

btopro’s picture

Status: Needs work » Needs review

needs to be in coder_upgrade.drush.inc

/**
 * 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);
}
btopro’s picture

StatusFileSize
new2.05 KB

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

djdevin’s picture

Status: Needs review » Reviewed & tested by the community

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

aendra’s picture

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

klausi’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Issue summary: View changes
Status: Reviewed & tested by the community » Needs work

This should go into Coder 7.x-2.x.

  1. +++ b/coder_upgrade/coder_upgrade.drush.inc
    @@ -0,0 +1,58 @@
    +      'Longer example' => 'drush my-command token spaces og',
    

    my-command? Copy and paste error?

  2. +++ b/coder_upgrade/coder_upgrade.drush.inc
    @@ -0,0 +1,58 @@
    +  // load generic list of arguments
    

    Please start all comments upper case and end with a dot.

  3. +++ b/coder_upgrade/coder_upgrade.drush.inc
    @@ -0,0 +1,58 @@
    +    drush_log('coder-upgrade requires arugments, run drush help coder-upgrade for details.', 'error');  ¶
    

    Trailing whitespace, "arugments" typo.

  4. +++ b/coder_upgrade/coder_upgrade.drush.inc
    @@ -0,0 +1,58 @@
    \ No newline at end of file
    

    missing newline.

klausi’s picture

Status: Needs work » Closed (won't fix)

Coder 7.x is frozen now and will not receive updates. Coder 8.x-2.x can be used to check code for any Drupal version, Coder 8.x-2.x also supports the phpcbf command to automatically fix conding standard errors. Please check if this issue is still relevant and reopen against that version if necessary.