function drush_variable_get

8.0.x variable.drush.inc drush_variable_get()
6.x variable.drush.inc drush_variable_get()
7.x variable.drush.inc drush_variable_get()
3.x variable.drush.inc drush_variable_get()
4.x variable.drush.inc drush_variable_get()
5.x variable.drush.inc drush_variable_get()
master variable.drush.inc drush_variable_get()

Command callback. List your site's variables.

File

commands/core/variable.drush.inc, line 129

Code

function drush_variable_get() {
  global $conf;
  $exact = drush_get_option('exact', FALSE);

  $keys = array_keys($conf);
  if ($args = func_get_args()) {
    $args[0] = drush_variable_name_adjust($args[0]);
    if ($exact) {
      $keys = in_array($args[0], $keys) ? array($args[0]) : array();
    }
    $keys = preg_grep("/{$args[0]}/", $keys);
  }

  // In --exact mode, if --pipe is not set, then simplify the return type.
  if ($exact && !drush_get_context('DRUSH_PIPE')) {
    $key = reset($keys);
    $returns = isset($conf[$key]) ? $conf[$key] : FALSE;
  }
  else {
    foreach ($keys as $name) {
      $value = $conf[$name];
      $returns[$name] = $value;
    }
  }
  if (empty($keys)) {
    return drush_set_error('No matching variable found.');
  }
  else {
    return $returns;
  }
}