Skip to content

Instantly share code, notes, and snippets.

@a2ikm
Created September 11, 2011 13:26
Show Gist options
  • Save a2ikm/1209575 to your computer and use it in GitHub Desktop.
Save a2ikm/1209575 to your computer and use it in GitHub Desktop.
generate .rvmrc
#!/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