You are here

function drush_coder_format in Coder 7

Same name and namespace in other branches
  1. 7.2 coder.drush.inc \drush_coder_format()

Drush command callback for coder-format.

File

./coder.drush.inc, line 43
Drush integration for Coder module.

Code

function drush_coder_format() {
  $path = drush_get_context('DRUSH_DRUPAL_ROOT');
  $path .= '/' . drupal_get_path('module', 'coder') . '/scripts/coder_format/coder_format.inc';
  require_once $path;
  $undo = drush_get_option('undo', FALSE);
  $files = func_get_args();
  $cwd = drush_get_context('DRUSH_OLDCWD');
  foreach ($files as $file) {

    // Additionally support relative paths.
    // Do this first to prevent typo disasters (e.g., $file == '/').
    if (is_dir($cwd . '/' . $file)) {
      coder_format_recursive($cwd . '/' . $file, $undo);
    }
    elseif (file_exists($cwd . '/' . $file)) {
      coder_format_file($cwd . '/' . $file, $undo);
    }
    elseif (is_dir($file)) {
      coder_format_recursive($file, $undo);
    }
    else {
      coder_format_file($file, $undo);
    }
  }
}