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 70

Code

function drush_variable_get() {
  global $conf;
  $found = FALSE;

  $keys = array_keys($conf);
  if ($args = func_get_args()) {
    $keys = preg_grep("/{$args[0]}/", $keys);
  }
  foreach ($keys as $name) {
    $value = $conf[$name];
    drush_print_pipe("\$variables['$name'] = " . var_export($value, TRUE) . ";\n");
    $returns[$name] = $value;

    if ($value === TRUE) {
      $value = 'TRUE';
    }
    elseif ($value === FALSE) {
      $value = 'FALSE';
    }
    elseif (is_string($value)) {
      $value = '"' . $value . '"';
    }
    elseif (is_array($value) || is_object($value)) {
      $value = print_r($value, TRUE);
    }
    drush_print($name . ': ' . $value);
    $found = TRUE;
  }

  if (!$found) {
    return drush_set_error('No matching variable found.');
  }
  else {
    return $returns;
  }
}