Sha256: b6cc543118e5603bf629a9adcfa3c197b0b4beb334a447a67cb7d6d3a54ec5b6

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require "thor"

require_relative "../session"
require_relative "./constants"

module NeetoDeploy
  class CLI
    module Addon
      class ScheduledExportsSettings < CLI::Base
        include Constants
        include Session

        attr_reader :app_name

        def initialize(options)
          super()
          @app_name = options[:app]
        end

        def run
          ui.execute_with_loading("Fetching info...") do
            send_request
          end
          print_output
        end

        private

          def send_request
            @response = send_get_request("#{NEETO_DEPLOY_CLI_API_BASE_URL}/scheduled_exports/#{app_name}", {app_slug: app_name})
          end

          def print_output
            ui.error(@response["error"]) and return unless @response.success?

            scheduled_exports = JSON.parse(@response.body)["scheduled_exports_enabled"]
            if scheduled_exports.nil?
              ui.error("App doesn't seem to have a primary database addon")
            else
              ui.info("Scheduled exports is turned #{scheduled_exports ? "\u001b[32mon\u001b[0m" : "\u001b[31moff\u001b[0m"} for #{app_name}'s primary database")
            end
          end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
neetodeploy-1.1.13 lib/neeto_deploy/cli/addon/scheduled_exports_settings.rb
neetodeploy-1.1.12 lib/neeto_deploy/cli/addon/scheduled_exports_settings.rb
neetodeploy-1.1.11 lib/neeto_deploy/cli/addon/scheduled_exports_settings.rb