Created
September 11, 2011 13:26
-
-
Save a2ikm/1209575 to your computer and use it in GitHub Desktop.
generate .rvmrc
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'micro-optparse' | |
options = Parser.new { |p| | |
p.banner = "Generate .rvmrc file." | |
p.version = "0.1" | |
p.option :ruby, "Version of Ruby interpreter installed with RVM", :default => RUBY_VERSION | |
p.option :gemset, "Name of RVM gemset", :default => File.basename(`pwd`.strip) | |
p.option :force, "Write file whether it exists or not", :default => false | |
}.process! | |
file = ".rvmrc" | |
if File.exist? file and !options[:force] | |
abort "#{file} already exists!" | |
else | |
line = "rvm use #{options[:ruby]}@#{options[:gemset]}" | |
File.open(file, "w") { |f| f.write(line) } | |
puts %(Write "#{line}" to #{file}.) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment