Class: TranslateClient::CLI::AuthCommands

Inherits:
Base
  • Object
show all
Defined in:
lib/translate_client/cli/auth.rb

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?, start

Instance Method Details

#loginObject



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 
  authenticator = Auth.new(api, credentials)

  viewer = authenticator.viewer
  if viewer
    puts "You're already logged in as #{viewer.email}."
    return
  end

  viewer = authenticator. do |redirect_url|
    puts "Opening #{redirect_url} ..."
    Launchy.open(redirect_url)
  end

  puts "You're now logged in as #{viewer.email}."
end

#logoutObject



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

#whoamiObject



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