You are here

function drush_hacked_list_projects in Hacked! 8.2

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

Drush command callback that shows the listing of changed/unchanged projects.

File

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

Code

function drush_hacked_list_projects() {

  // Go get the data:
  module_load_include('inc', 'update', 'update.report');
  if ($available = update_get_available(TRUE)) {
    module_load_include('inc', 'update', 'update.compare');
    $data = update_calculate_project_data($available);
    $force_rebuild = drush_get_option('force-rebuild', FALSE);
    $projects = hacked_calculate_project_data_drush($data, $force_rebuild);

    // Now print the data using drush:
    $rows[] = [
      dt('Title'),
      dt('Name'),
      dt('Version'),
      dt('Status'),
      dt('Changed'),
      dt('Deleted'),
    ];
    foreach ($projects as $project) {
      $row = [
        $project['title'],
        $project['name'],
        $project['existing_version'],
      ];

      // Now add the status:
      switch ($project['status']) {
        case HACKED_STATUS_UNHACKED:
          $row[] = dt('Unchanged');
          break;
        case HACKED_STATUS_HACKED:
          $row[] = t('Changed');
          break;
        case HACKED_STATUS_UNCHECKED:
        default:
          $row[] = t('Unchecked');
          break;
      }
      $row[] = $project['counts']['different'];
      $row[] = $project['counts']['missing'];
      $rows[] = $row;
    }
    drush_print_table($rows, TRUE);
    return $projects;
  }
}