Class: Aptible::CLI::Agent

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

Instance Method Summary collapse

Methods included from Subcommands::Tunnel

included

Methods included from Subcommands::SSH

included

Methods included from Subcommands::Config

included

Methods included from Helpers::Token

#current_token_hash, #fetch_token, #save_token, #token_file

Instance Method Details

#login ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/aptible/cli/agent.rb', line 31

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

#version ⇒ Object



24
25
26
# File 'lib/aptible/cli/agent.rb', line 24

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