class Envirobly::Defaults::Account
def require_value
def require_value api = Envirobly::Api.new accounts = api.list_accounts if accounts.object.blank? shell.say_error "Please connect an AWS account to your Envirobly account first." exit 1 end # If only one account exists, it will be used id = accounts.object.first.fetch("id") if accounts.object.size > 1 puts "Choose default account to deploy this project to:" data = [ [ "ID", "Name", "AWS number", "URL" ] ] + accounts.object.pluck("id", "name", "aws_id", "url") shell.print_table data, borders: true limited_to = accounts.object.pluck("id").map(&:to_s) begin id = shell.ask("Type in the account ID:", limited_to:).to_i rescue Interrupt shell.say_error "Cancelled" exit end end save id shell.say "Account ##{id} set as project default " shell.say green_check id end