Class: Aptible::CLI::Agent

Inherits:
Thor
  • Object
show all
Includes:
Helpers::Token, Subcommands::Apps, Subcommands::Config, Subcommands::DB, Subcommands::Rebuild, Subcommands::Restart, Subcommands::SSH, Thor::Actions
Defined in:
lib/aptible/cli/agent.rb

Instance Method Summary collapse

Methods included from Subcommands::SSH

included

Methods included from Subcommands::Restart

included

Methods included from Subcommands::Rebuild

included

Methods included from Subcommands::DB

included

Methods included from Subcommands::Config

included

Methods included from Subcommands::Apps

included

Methods included from Helpers::Token

#current_token_hash, #fetch_token, #save_token, #token_file

Instance Method Details

#loginObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/aptible/cli/agent.rb', line 38

def 
  email = options[:email] || ask('Email: ')
  password = options[:password] || ask('Password: ', echo: false)
  puts ''

  begin
    token = Aptible::Auth::Token.create(email: email, password: password)
  rescue OAuth2::Error
    raise Thor::Error, 'Could not authenticate with given credentials'
  end

  save_token(token.access_token)
  puts "Token written to #{token_file}"
end

#versionObject



31
32
33
# File 'lib/aptible/cli/agent.rb', line 31

def version
  puts "aptible-cli v#{Aptible::CLI::VERSION}"
end