Sha256: 53be1858272f4779695e02c99cf07faeb4636d62f27acf9e812b2d479327a766
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
require 'aptible/api' require 'git' 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 fail 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 fail Thor::Error, "Could not find environment #{handle}" else ensure_default_environment end end def environment_from_handle(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) return environments.first if environments.count == 1 fail Thor::Error, <<-ERR.gsub(/\s+/, ' ').strip Multiple environments available, please specify with --environment ERR end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aptible-cli-0.6.0 | lib/aptible/cli/helpers/environment.rb |