Skip to content
This repository
Browse code

rvm switch /path/to/rvm

  • Loading branch information...
commit eb8473addaeab24fd4f7c91c0bdc045a5a7aa08c 1 parent e500672
Michal Papis authored September 06, 2012
7  HACKING.md
Source Rendered
@@ -21,9 +21,8 @@ the tests (you will need rvm already installed).
21 21
 You need a test rvm install to run the test suite against:
22 22
 
23 23
     $ git clone https://github.com/wayneeseguin/rvm  # or your own github fork
24  
-    $ export rvm_path=~/path/to/rvm/test/install     # choose a path here
25  
-    $ export rvm_bin_path=$rvm_path/bin
26 24
     $ cd rvm
  25
+    $ rvm switch ~/path/to/rvm/test/install          # choose a path here
27 26
     $ ./install
28 27
 
29 28
 This will create a test installation of rvm in
@@ -37,6 +36,10 @@ you also need to do:
37 36
 
38 37
     $ rvm reload
39 38
 
  39
+To get back to using orginal rvm installation run:
  40
+
  41
+    $ rvm switch ~/.rvm
  42
+
40 43
 ## Hacking RVM via TDD (Test-Driven Development)
41 44
 
42 45
 First write a test for the behaviour you expect.  For details on how
13  scripts/cli
@@ -256,7 +256,7 @@ __rvm_parse_args()
256 256
             rvm_parse_break=1
257 257
             ;;
258 258
 
259  
-          docs|alias|rubygems|cleanup|tools|disk-usage|snapshot|repair|migrate|upgrade|cron)
  259
+          docs|alias|rubygems|cleanup|tools|disk-usage|snapshot|repair|migrate|upgrade|cron|group|switch)
260 260
             rvm_action="$rvm_token"
261 261
             rvm_ruby_args=("$next_token" "$@")
262 262
             rvm_parse_break=1
@@ -302,12 +302,6 @@ __rvm_parse_args()
302 302
             fi
303 303
             ;;
304 304
 
305  
-          group)
306  
-            rvm_action="group"
307  
-            rvm_ruby_args=("$next_token" "$@")
308  
-            rvm_parse_break=1
309  
-            ;;
310  
-
311 305
           alt*)
312 306
             rvm_action="help"
313 307
             rvm_ruby_args=("alt.md")
@@ -864,6 +858,11 @@ Please do one of the following:
864 858
       then __rvm_use
865 859
       fi
866 860
       ;;
  861
+    switch)
  862
+      if rvm_is_a_shell_function
  863
+      then __rvm_switch "${rvm_ruby_args[@]}"
  864
+      fi
  865
+      ;;
867 866
     srcdir)
868 867
       __rvm_source_dir
869 868
       ;;
33  scripts/functions/env
@@ -144,3 +144,36 @@ __rvm_remove_rvm_from_path()
144 144
   __rvm_remove_from_path "${rvm_path}"
145 145
   builtin hash -r
146 146
 }
  147
+
  148
+__rvm_switch()
  149
+{
  150
+  typeset new_rvm_path new_rvm_bin_path
  151
+
  152
+  (( $# )) && [[ -z "$1" ]] && shift || true # skip first empty argument
  153
+  (( $# )) && [[ -n "$1" ]] && [[ -d "$1" || -d "${1%/*}" ]] && [[ ! -f "$1" ]] ||
  154
+  {
  155
+    rvm_error "No valid path given."
  156
+    return 1
  157
+  }
  158
+  [[ "${rvm_path}" != "${new_rvm_path}" ]] ||
  159
+  {
  160
+    rvm_warn "Already there!"
  161
+    return 2
  162
+  }
  163
+  rvm_log "Switching ${rvm_path} => ${1}"
  164
+
  165
+  new_rvm_path="${1%/}"
  166
+  new_rvm_bin_path="${2:-$new_rvm_path/bin}"
  167
+  new_rvm_bin_path="${new_rvm_bin_path%/}"
  168
+
  169
+  __rvm_use_system
  170
+  __rvm_remove_from_path "${rvm_path}"
  171
+
  172
+  rvm_reload_flag=1
  173
+  rvm_path="${new_rvm_path}"
  174
+  rvm_bin_path="${new_rvm_bin_path}"
  175
+  rvm_scripts_path="${rvm_path}/scripts"
  176
+
  177
+  __rvm_remove_from_path "${rvm_path}"
  178
+  __rvm_add_to_path prepend "${rvm_bin_path}"
  179
+}

0 notes on commit eb8473a

Please sign in to comment.
Something went wrong with that request. Please try again.