Module: Aptible::CLI::Helpers::Account

Includes:
Token
Defined in:
lib/aptible/cli/helpers/account.rb

Instance Method Summary collapse

Methods included from Token

#current_token_hash, #fetch_token, #save_token, #token_file

Instance Method Details

#account_from_handle(handle) ⇒ Object



20
21
22
23
24
# File 'lib/aptible/cli/helpers/account.rb', line 20

def (handle)
  Aptible::Api::Account.all(token: fetch_token).find do |a|
    a.handle == handle
  end
end

#ensure_account(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/aptible/cli/helpers/account.rb', line 10

def (options = {})
  if (handle = options[:account])
     = (handle)
    return  if 
    fail "Could not find account #{handle}"
  else
    
  end
end

#ensure_default_accountObject



26
27
28
29
30
31
32
33
# File 'lib/aptible/cli/helpers/account.rb', line 26

def 
  accounts = Aptible::Api::Account.all(token: fetch_token)
  return accounts.first if accounts.count == 1

  fail Thor::Error, <<-ERR.gsub(/\s+/, ' ').strip
    Multiple accounts available, please specify with --account
  ERR
end