Class: Turbot::Command::Auth
Overview
Login or logout from Turbot
Constant Summary
Constants included from Helpers
Instance Method Summary collapse
-
#index ⇒ Object
auth.
-
#login ⇒ Object
auth:login.
-
#logout ⇒ Object
auth:logout.
-
#token ⇒ Object
auth:token.
-
#whoami ⇒ Object
auth:whoami.
Methods included from Helpers
#api, #ask, #ask_for_password, #ask_for_password_on_windows, #delete_netrc_entry, #email_address_and_api_key, #error, #format_error, #host, #netrc_exists?, #netrc_path, #open_netrc, #save_netrc_entry, #styled_error, #turbot_api, #turbot_api_parameters
Constructor Details
This class inherits a constructor from Turbot::Command::Base
Instance Method Details
#index ⇒ Object
auth
Login or logout. Display your Turbot API token or email address.
7 8 9 10 |
# File 'lib/turbot/command/auth.rb', line 7 def index validate_arguments! Turbot::Command::Help.new.send(:help_for_command, current_command) end |
#login ⇒ Object
auth:login
Login to Turbot and save your Turbot credentials.
Example:
$ turbot auth:login Enter your Turbot email and password: Email: [email protected] Password (typing will be hidden): Logged in. Saved Turbot API key.
24 25 26 27 28 29 30 31 32 |
# File 'lib/turbot/command/auth.rb', line 24 def login validate_arguments! email_address, api_key = ask_for_email_address_and_password if api_key.empty? error 'Authentication failed.' end save_netrc_entry(email_address, api_key) puts 'Authentication successful.' end |
#logout ⇒ Object
auth:logout
Delete your Turbot credentials.
Example:
$ turbot auth:logout Deleted Turbot credentials.
44 45 46 47 48 |
# File 'lib/turbot/command/auth.rb', line 44 def logout validate_arguments! delete_netrc_entry puts 'Deleted Turbot credentials.' end |
#token ⇒ Object
auth:token
Display your Turbot API token.
Example:
$ turbot auth:token 93a5c45595ed37dc9d040116
60 61 62 63 64 65 66 67 68 |
# File 'lib/turbot/command/auth.rb', line 60 def token validate_arguments! result = email_address_and_api_key[1] if result puts result else error 'not logged in' end end |
#whoami ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'lib/turbot/command/auth.rb', line 79 def whoami validate_arguments! result = email_address_and_api_key[0] if result puts result else error 'not logged in' end end |