You are here

function drush_hacked_details in Hacked! 5

Same name and namespace in other branches
  1. 8.2 hacked.drush.inc \drush_hacked_details()
  2. 6.2 hacked.drush.inc \drush_hacked_details()
  3. 6 hacked.drush.inc \drush_hacked_details()
  4. 7.2 hacked.drush.inc \drush_hacked_details()

Drush command callback that shows the list of changes/unchanged files in a project.

You may specify the --include-unchanged option to show unchanged files too, otherwise just the changed and deleted files are shown.

File

./hacked.drush.inc, line 119
Hacked drush command.

Code

function drush_hacked_details($short_name = '') {
  $project = hacked_project_load($short_name);
  if (!$project) {
    return drush_set_error('HACKED_PROJECT_NOT_FOUND', dt('Could not find project: !project', array(
      '!project' => $short_name,
    )));
  }
  drush_print(dt('Details for project: @name', array(
    '@name' => $project['title'],
  )));
  drush_print(dt('Total files: @total_files, files changed: @changed_files, deleted files: @deleted_files', array(
    '@total_files' => count($project['hacked_results']),
    '@changed_files' => $project['changed_count'],
    '@deleted_files' => $project['deleted_count'],
  )));
  drush_print('');
  drush_print(dt('Detailed results:'));

  // Sort the results:
  arsort($project['hacked_results']);
  $rows[] = array(
    dt('Status'),
    dt('File'),
  );
  $show_unchanged = drush_get_option('include-unchanged', FALSE);
  foreach ($project['hacked_results'] as $file => $status) {
    if (!$show_unchanged && $status == HACKED_STATUS_UNHACKED) {
      continue;
    }
    $row = array();

    // Now add the status:
    switch ($status) {
      case HACKED_STATUS_UNHACKED:
        $row[] = dt('Unchanged');
        break;
      case HACKED_STATUS_HACKED:
        $row[] = t('Changed');
        break;
      case HACKED_STATUS_DELETED:
        $row[] = t('Deleted');
        break;
      case HACKED_STATUS_UNCHECKED:
      default:
        $row[] = t('Unchecked');
        break;
    }
    $row[] = $file;
    $rows[] = $row;
  }
  drush_print_table($rows, TRUE);
}