Class: UnimatrixCLI::LoginCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/unimatrix_cli/login_command.rb

Constant Summary collapse

ENVIRONMENTS =
%w( development acceptance staging production )
REGIONS =
%w( us-east-1 us-west-2 )

Instance Method Summary collapse

Methods inherited from Command

available_commands, descendants, #initialize, #read_file, #validate, #validate_collection, #write

Methods included from UnimatrixParser

included

Constructor Details

This class inherits a constructor from UnimatrixCLI::Command

Instance Method Details

#executeObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/unimatrix_cli/login_command.rb', line 19

def execute
  if save_environment
    save_region

    response = 
    if response[ 'access_token' ].nil?
      write( message: "Error logging in: #{ response.inspect }", error: true )
    else
      save_access_token( response[ 'access_token' ] )
      write( message: 'Successfully logged in; saving access_token and environment' )
    end
  else
    write( message: 'Invalid environment', error: true )
  end
end