You are here

function coder_drush_review in Coder 6.2

Same name and namespace in other branches
  1. 5.2 coder.drush.inc \coder_drush_review()
  2. 6 coder.drush.inc \coder_drush_review()
1 string reference to 'coder_drush_review'
coder_drush_command in ./coder.drush.inc
Implements hook_drush_command().

File

./coder.drush.inc, line 72
Command line utility for coder.

Code

function coder_drush_review() {
  _coder_drush_set_option('drush');

  // process command line arguments
  $args = func_get_args();
  $reviews = array();
  $modules = array();
  $output = array();
  $settings = _coder_get_default_settings();
  if (count($args)) {
    $avail_reviews = _coder_reviews();
    foreach ($args as $arg) {
      switch ($arg) {
        case 'summary':
        case 'no-empty':
        case 'xml':
        case 'checkstyle':
          _coder_drush_set_option($arg);
          break;
        case 'active':
        case 'core':
        case 'contrib':
        case 'all':
        case 'default':
          $settings = _coder_get_default_settings($arg);
          $settings['coder_includes'] = TRUE;
          break;
        case 'major':
        case 'minor':
        case 'critical':
          $severity_name = $arg;
          break;
        default:
          if (isset($avail_reviews[$arg])) {
            $reviews[$arg] = $arg;
          }
          elseif (drupal_substr($arg, 0, 3) == 'no-') {
            _coder_set_form_modules($settings);
            unset($settings['coder_modules-' . drupal_substr($arg, 3)]);
          }
          else {
            if (_coder_drush_is_patch_arg($arg)) {
              $settings['coder_patches'] = 1;
              $settings['coder_patch_link'] = $arg;
            }
            else {
              $settings['coder_modules-' . $arg] = 1;
              $settings['coder_includes'] = TRUE;
            }
            unset($settings['coder_active_modules']);
            unset($settings['coder_core']);
            unset($settings['coder_all']);
            unset($settings['coder_modules']);
          }
          break;
      }
    }
    if (_coder_drush_is_option('checkstyle')) {
      _coder_drush_xml_output_header('checkstyle');
    }
    elseif (_coder_drush_is_option('xml')) {
      _coder_drush_xml_output_header('xml');
    }
    if (isset($severity_name)) {
      if (_coder_drush_is_option('xml')) {
        _coder_drush_xml_output_severity($severity_name);
      }
      $output[] = dt('Severity @severity_name', array(
        '@severity_name' => $severity_name,
      ));
      $settings['coder_severity'] = _coder_severity($severity_name);
    }
    if (count($reviews)) {
      if (_coder_drush_is_option('xml') && !_coder_drush_is_option('checkstyle')) {
        _coder_drush_xml_output_reviews($reviews, $avail_reviews);
      }
      else {
        foreach ($reviews as $review) {
          $output[] = $avail_reviews[$review]['#title'];
        }
      }
      $settings['coder_reviews'] = $reviews;
    }
    if (count($output) && !_coder_drush_is_option('summary') && !_coder_drush_is_option('xml') && !_coder_drush_is_option('checkstyle')) {
      drush_print(implode(', ', $output) . "\n");
    }
  }
  _coder_set_form_modules($settings);
  $settings['op'] = 'drush';
  $form_state['storage'] = $settings;
  coder_page_form($form_state);
  if (_coder_drush_is_option('checkstyle')) {
    _coder_drush_xml_output_footer('checkstyle');
  }
  elseif (_coder_drush_is_option('xml')) {
    _coder_drush_xml_output_footer('xml');
  }
}