Skip to content

Instantly share code, notes, and snippets.

@tylerhunt
Created July 11, 2011 15:25
Show Gist options
  • Save tylerhunt/1076085 to your computer and use it in GitHub Desktop.
Save tylerhunt/1076085 to your computer and use it in GitHub Desktop.
Switches Keys for Multiple Heroku Accounts
#!/usr/bin/ruby
require 'fileutils'
account = ARGV.first
unless account
puts "Usage: #{File.basename(__FILE__)} <account>"
exit(1)
end
heroku_path = File.expand_path(File.join('~', '.heroku'))
account_path = File.join(heroku_path, 'accounts', account)
credentials_path = File.join(heroku_path)
if File.directory?(account_path)
Dir[File.join(account_path, '*')].each do |file|
puts "Copying #{file}"
FileUtils.cp(file, credentials_path)
end
puts "Switched to #{account}."
else
puts 'Invalid account.'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment