Class: Travis::CLI::Login

Inherits:
ApiCommand show all
Defined in:
lib/travis/cli/login.rb

Instance Attribute Summary collapse

Attributes inherited from ApiCommand

#session

Attributes inherited from Command

#arguments, #config, #force_interactive, #formatter, #input, #output

Instance Method Summary collapse

Methods inherited from ApiCommand

#authenticate, #detected_endpoint?, #endpoint_config, #initialize, #org?, #pro?, #setup, #sync

Methods included from Travis::Client::Methods

#access_token, #access_token=, #accounts, #api_endpoint, #api_endpoint=, #artifact, #broadcasts, #build, #cancel, #explicit_api_endpoint?, #github_auth, #job, #listen, #repo, #repos, #restart, #user, #worker, #workers

Methods inherited from Command

abstract, abstract?, #check_ruby, #check_version, command_name, #command_name, #debug, description, #execute, #help, #info, #initialize, #last_check, #on_signal, #parse, #say, #setup, skip, #terminal, #usage, #write_to

Methods included from Parser

#new, #on, #on_initialize

Constructor Details

This class inherits a constructor from Travis::CLI::ApiCommand

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



13
14
15
# File 'lib/travis/cli/login.rb', line 13

def callback
  @callback
end

#github_loginObject

Returns the value of attribute github_login.



13
14
15
# File 'lib/travis/cli/login.rb', line 13

def 
  @github_login
end

#github_otpObject

Returns the value of attribute github_otp.



13
14
15
# File 'lib/travis/cli/login.rb', line 13

def github_otp
  @github_otp
end

#github_passwordObject

Returns the value of attribute github_password.



13
14
15
# File 'lib/travis/cli/login.rb', line 13

def github_password
  @github_password
end

#github_tokenObject

Returns the value of attribute github_token.



13
14
15
# File 'lib/travis/cli/login.rb', line 13

def github_token
  @github_token
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
# File 'lib/travis/cli/login.rb', line 15

def run
  self.github_token ||= Travis::Tools::TokenFinder.find(:explode => explode?, :github => github_endpoint.host) if auto?
  generate_github_token unless github_token
  endpoint_config['access_token'] = github_auth(github_token)
  success("Successfully logged in!")
ensure
  callback.call if callback
end