Created
November 22, 2010 02:00
-
-
Save authorNari/709419 to your computer and use it in GitHub Desktop.
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
diff --git a/lib/plugins/defaults/switch.rb b/lib/plugins/defaults/switch.rb | |
index 266ab60..83141cb 100644 | |
--- a/lib/plugins/defaults/switch.rb | |
+++ b/lib/plugins/defaults/switch.rb | |
@@ -10,18 +10,30 @@ module Termtter::Client | |
passwords[config.user_name] = config.password | |
- if user_name | |
- config.user_name = normalize_as_user_name(arg) | |
- if passwords.key?(config.user_name) | |
- config.password = passwords[config.user_name] | |
- else | |
- config.__clear__(:password) | |
+ file_name_prefix = File.join(Termtter::CONF_DIR, config.token_file_name) | |
+ unless user_name | |
+ choices = [:new, ""] | |
+ choices += Dir.glob(file_name_prefix + "_*").map{|f| f.gsub(file_name_prefix+'_', '')} | |
+ | |
+ puts "0. New user" | |
+ puts "1. Default" | |
+ choices[2..-1].each_with_index do |c, i| | |
+ puts "#{i+2}. #{c}" | |
+ end | |
+ ui = create_highline | |
+ choice = choices[ui.ask("Please choice number: ").to_i] | |
+ if choice.nil? | |
+ puts "Invalid number" | |
+ break | |
end | |
- else | |
- config.__clear__(:user_name) | |
- config.__clear__(:password) | |
+ user_name = (choice == :new) ? ui.ask("Enter user name: ") : choice | |
end | |
+ config.token_file = file_name_prefix | |
+ config.token_file += "_#{user_name}" if user_name != "" | |
+ config.__clear__(:access_token) | |
+ config.__clear__(:access_token_secret) | |
+ | |
Termtter::API.setup | |
execute('reload') | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment