From eba58f7b34ab818e55ca53bf5a55f048b5685e9d Mon Sep 17 00:00:00 2001
From: James Sansbury <james.sansbury@lullabot.com>
Date: Mon, 27 Jun 2011 17:38:21 -0400
Subject: [PATCH] #1201818 by q0rban: Add some basic drush commands to
 interface with the Variable module API.

---
 variable.drush.inc |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)
 create mode 100644 variable.drush.inc

diff --git a/variable.drush.inc b/variable.drush.inc
new file mode 100644
index 0000000..01f8b12
--- /dev/null
+++ b/variable.drush.inc
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * @file
+ * Drush commands for Variable module.
+ */
+
+/**
+ * Implements hook_drush_command().
+ */
+function variable_api_drush_command() {
+  $items['variable-get-info'] = array(
+    'description' => dt('Display information about a variable.'),
+    'arguments' => array(
+      'name' => dt('The name of the Variable.'),
+    ),
+    'drupal dependencies' => array('variable'),
+    'aliases' => array('vgeti'),
+  );
+
+  $items['variable-get-value'] = array(
+    'description' => dt('Get the value of a variable, or the default if none exists.'),
+    'arguments' => array(
+      'name' => dt('The name of the Variable.'),
+    ),
+    'drupal dependencies' => array('variable'),
+    'aliases' => array('vgetv'),
+  );
+
+  return $items;
+}
+
+function drush_variable_get_info($name = NULL) {
+  drush_print_r(variable_get_info($name));
+}
+
+function drush_variable_get_value($name) {
+  foreach ($keys as $name) {
+    $value = $conf[$name];
+    drush_print_pipe("\$variables['$name'] = ". var_export($value, TRUE). ";\n");
+
+    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;
+  }
+}
\ No newline at end of file
-- 
1.7.5.4

