Sha256: 783f9ebd15c7c9d576e0807479c3e9d83680647e0b76676f7ebb9990b86ec5fb
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
require 'aptible/api' module Aptible module CLI module Helpers module Environment include Helpers::Token def scoped_environments(options) if options[:environment] if (environment = environment_from_handle(options[:environment])) [environment] else raise Thor::Error, 'Specified account does not exist' end else Aptible::Api::Account.all(token: fetch_token) end end def ensure_environment(options = {}) if (handle = options[:environment]) environment = environment_from_handle(handle) return environment if environment raise Thor::Error, "Could not find environment #{handle}" else ensure_default_environment end end def environment_from_handle(handle) return nil unless handle Aptible::Api::Account.all(token: fetch_token).find do |a| a.handle == handle end end def ensure_default_environment environments = Aptible::Api::Account.all(token: fetch_token) case environments.count when 0 e = 'No environments. Go to https://app.aptible.com/ to proceed' raise Thor::Error, e when 1 return environments.first else raise Thor::Error, <<-ERR.gsub(/\s+/, ' ').strip Multiple environments available, please specify with --environment or --env ERR end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aptible-cli-0.24.2 | lib/aptible/cli/helpers/environment.rb |
aptible-cli-0.24.1 | lib/aptible/cli/helpers/environment.rb |