You are here

function _drush_features_component_find in Features 6

Help the user select a Features component if one can be recommended.

Parameters

$arg: A specific component to search for. Used as variable-get command.

$source: Restrict component lookup to the specified source.

$limit: Limit the number of options that will be offered. If "0", no limit. If the limit is reached, send back all. Default: 10.

1 call to _drush_features_component_find()
drush_features_add in ./features.drush.inc
Add a component to a features module.

File

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

Code

function _drush_features_component_find($arg = NULL, $source = NULL, $limit = 10) {
  $components = _drush_features_component_list($arg, $source, FALSE);
  $count = count($components);
  if (!empty($components)) {
    if ($limit > 0 && $count > $limit) {
      $proceed = drush_confirm(dt('There are !count components that may match "!component". Review all?', array(
        '!count' => $count,
        '!component' => $source . ':' . $arg,
      )));
    }
    else {
      $proceed = TRUE;
    }
    if ($proceed) {
      $choice = drush_choice($components, 'Enter a number to choose which component to use.');
      if ($choice !== FALSE) {
        $retn = new stdClass();
        list($retn->source, $retn->component) = explode(':', $components[$choice]);
        return $retn;
      }
    }
  }
  else {
    $components = _drush_features_component_list($arg, $source, TRUE);
  }
  return FALSE;
}