Created
August 24, 2011 11:47
-
-
Save anonymous/1167900 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/commands/core/sitealias.drush.inc b/commands/core/sitealias.drush.inc | |
index 5352fd5..4f1ae22 100644 | |
--- a/commands/core/sitealias.drush.inc | |
+++ b/commands/core/sitealias.drush.inc | |
@@ -39,6 +39,21 @@ function sitealias_drush_command() { | |
), | |
'topics' => array('docs-aliases'), | |
); | |
+ $items['site-set'] = array( | |
+ 'description' => '', | |
+ 'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, | |
+ 'arguments' => array( | |
+ 'site' => 'Site specification alias to use.', | |
+ ), | |
+ ); | |
+ $items['site-get'] = array( | |
+ 'description' => '', | |
+ 'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, | |
+ ); | |
+ $items['site-reset'] = array( | |
+ 'description' => '', | |
+ 'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, | |
+ ); | |
return $items; | |
} | |
@@ -283,3 +298,60 @@ function _drush_sitealias_site_dir_to_uri($site_dir) { | |
return 'http://' . $uri; | |
} | |
+ | |
+ | |
+/** | |
+ * | |
+ */ | |
+function drush_sitealias_site_set($site = NULL) { | |
+ drush_print_r($site); | |
+// $siteenv = getenv('DRUSH_SITE'); | |
+ _drush_cache_get('drush_site'); | |
+ // drush_print_r($siteenv); | |
+ | |
+ //if (_drush_sitealias_set_context_by_name($site) && $site == getenv('DRUSH_SITE')) { | |
+ if (_drush_sitealias_set_context_by_name($site)) { | |
+ _drush_cache_set('drush_site', $site); | |
+ // drush_print(dt("Successfully set site to !site.", array('!site' => $site))); | |
+ } | |
+ else { | |
+ drush_print(dt("Could not find a site definition for !site.", array('!site' => $site))); | |
+ } | |
+} | |
+ | |
+ | |
+/** | |
+ * | |
+ */ | |
+function drush_sitealias_site_get() { | |
+ if ($site = _drush_cache_get('drush_site')) { | |
+ drush_print($site->data); | |
+ } | |
+ else { | |
+ if (drush_get_context('DRUSH_VERBOSE')) { | |
+ drush_print(dt("No site definition currently set")); | |
+ } | |
+ } | |
+} | |
+ | |
+/** | |
+ * | |
+ */ | |
+function drush_sitealias_site_reset() { | |
+ _drush_cache_clear_all('drush_site'); | |
+ //system("unset DRUSH_SITE"); | |
+} | |
+ | |
+ | |
+function drush_save_rc_file($contents) { | |
+ $drushrc_file = drush_server_home() . '/.drushrc'; | |
+ //if (file_exists($rcpath)) { | |
+ //file_put_contents($rcpath, $contents, FILE_APPEND); | |
+ file_put_contents($drushrc_file, $contents); | |
+ // } | |
+ | |
+ $config_file = drush_server_home() . '/.profile'; | |
+ if (file_exists($config_file) && !drush_shell_exec("grep -q 'drushrc' %s", $config_file)) { | |
+ drush_shell_exec("echo 'source %s' >> %s", $drushrc_file, $config_file); | |
+ } | |
+} | |
diff --git a/includes/cache.inc b/includes/cache.inc | |
index 5054202..24ef43f 100644 | |
--- a/includes/cache.inc | |
+++ b/includes/cache.inc | |
@@ -306,7 +306,7 @@ class DrushFileCache implements DrushCacheInterface { | |
function __construct($bin = NULL) { | |
$this->bin = $bin; | |
- $this->directory = $this->cacheDirectory(); | |
+ $this->directory = $this->cacheDirectory($bin); | |
} | |
function cacheDirectory($bin = NULL) { | |
diff --git a/includes/sitealias.inc b/includes/sitealias.inc | |
index c7da194..d16042e 100644 | |
--- a/includes/sitealias.inc | |
+++ b/includes/sitealias.inc | |
@@ -28,7 +28,10 @@ function drush_sitealias_check_arg() { | |
drush_set_arguments($args); | |
return TRUE; | |
} | |
- | |
+ // Check if we have a site cached. | |
+ if ($drush_site = _drush_cache_get('drush_site')) { | |
+ _drush_sitealias_set_context_by_name($drush_site->data); | |
+ } | |
// Return false to indicate that no site alias was specified. | |
return FALSE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment