Class: TranslateClient::CLI::AuthCommands
- Defined in:
- lib/translate_client/cli/auth.rb
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#login ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/translate_client/cli/auth.rb', line 7 def login authenticator = Auth.new(api, credentials) viewer = authenticator.viewer if viewer puts "You're already logged in as #{viewer.email}." return end viewer = authenticator.login do |redirect_url| puts "Opening #{redirect_url} ..." Launchy.open(redirect_url) end puts "You're now logged in as #{viewer.email}." end |
#logout ⇒ Object
25 26 27 28 |
# File 'lib/translate_client/cli/auth.rb', line 25 def logout Auth.new(api, credentials).logout puts "You're logged out." end |
#whoami ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/translate_client/cli/auth.rb', line 31 def whoami viewer = Auth.new(api, credentials).viewer if viewer puts "You're logged in as #{viewer.email}." else raise PresentableError.new("You're logged out.") end end |