You are here

function drush_hacked_list_projects in Hacked! 7.2

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

Command callback for drush hacked_list_projects.

File

./hacked.drush.inc, line 175

Code

function drush_hacked_list_projects() {
  hacked_load_drush_dependencies();

  // 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[] = array(
      dt('Title'),
      dt('Name'),
      dt('Version'),
      dt('Status'),
      dt('Changed'),
      dt('Deleted'),
    );
    foreach ($projects as $project) {
      $row = array(
        $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[] = dt('Changed');
          break;
        case HACKED_STATUS_UNCHECKED:
        default:
          $row[] = dt('Unchecked');
          break;
      }
      $row[] = $project['counts']['different'];
      $row[] = $project['counts']['missing'];
      $rows[] = $row;
    }
    drush_print_table($rows, TRUE);
    return $projects;
  }
}