You are here

function drush_features_list in Features 7.2

Same name and namespace in other branches
  1. 6 features.drush.inc \drush_features_list()
  2. 7 features.drush.inc \drush_features_list()

Drush command callback for 'features-list'.

Returns table rows for a list of all feature modules.

This is a drush command, but can also be called as a regular function. The drush command definition has an 'outputformat' key, which means that the result from this function will be further processed before it is printed.

Return value

string[][]|false Format: $[$row_name][column_name] = $cell_contents Table rows, or FALSE on failure. When used as a drush command, the table rows will be formatted according to the info in 'outputformat'.

2 calls to drush_features_list()
drush_features_diff in ./features.drush.inc
Show the diff of a feature module.
drush_features_revert in ./features.drush.inc
Drush command callback for 'features-revert'.

File

./features.drush.inc, line 246
Features module drush integration.

Code

function drush_features_list() {
  $status = drush_get_option('status') ? drush_get_option('status') : 'all';
  if (!in_array($status, array(
    'enabled',
    'disabled',
    'all',
  ))) {
    return drush_set_error('', dt('!status is not valid', array(
      '!status' => $status,
    )));
  }
  module_load_include('inc', 'features', 'features.export');

  // Sort the Features list before compiling the output.
  $features = features_get_features(NULL, TRUE);
  ksort($features);
  $rows = array();
  foreach ($features as $k => $m) {
    switch (features_get_storage($m->name)) {
      case FEATURES_DEFAULT:
      case FEATURES_REBUILDABLE:
        $storage = '';
        break;
      case FEATURES_OVERRIDDEN:
        $storage = dt('Overridden');
        break;
      case FEATURES_NEEDS_REVIEW:
        $storage = dt('Needs review');
        break;
    }
    if ($m->status == 0 && ($status == 'all' || $status == 'disabled') || $m->status == 1 && ($status == 'all' || $status == 'enabled')) {
      $rows[$k] = array(
        'name' => $m->info['name'],
        'feature' => $m->name,
        'status' => $m->status ? dt('Enabled') : dt('Disabled'),
        'version' => $m->info['version'],
        'state' => $storage,
      );
    }
  }
  if (version_compare(DRUSH_VERSION, '6.0', '<')) {
    drush_print_table($rows, TRUE);
  }
  return $rows;
}