Created
November 11, 2009 07:55
-
-
Save matthewtodd/231767 to your computer and use it in GitHub Desktop.
Handy Heroku credentials switcher.
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 -wKU | |
# I use 2 different Heroku accounts, one for my own apps and one for Amani's. | |
# This script givens me a reasonable way to switch between them, with a little | |
# less typing than moving a symlink around. And I get to use abbrev! | |
require 'abbrev' | |
require 'pathname' | |
require 'yaml' | |
credentials = Pathname.new(ENV['HOME']).join('.heroku', 'credentials') | |
config = YAML.load(DATA) | |
current_user = credentials.readlines.first.chomp | |
available_users = config.keys - [current_user] | |
selected_user = available_users.abbrev[ARGV.shift] | |
if password = config[selected_user] | |
puts "Re-authenticating as #{selected_user}." | |
credentials.open('w') do |file| | |
file.puts(selected_user) | |
file.puts(password) | |
end | |
else | |
puts "You are #{current_user}." | |
end | |
__END__ | |
[email protected]: ELIDED | |
[email protected]: ELIDED |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment