Sha256: 194f0fab18aead3ef22a74021708f33e03408f2a62da19823f8f630b993e7da7

Contents?: true

Size: 1.72 KB

Versions: 59

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

require_relative "base"

module Neetob
  class CLI
    module Heroku
      module ConfigVars
        class List < Base
          attr_accessor :apps, :sandbox, :keys, :required_config_vars_file_path

          def initialize(apps, keys = [], required_config_vars_file_path = "", sandbox = false)
            super()
            @apps = apps
            @sandbox = sandbox
            @keys = keys
            @required_config_vars_file_path = required_config_vars_file_path
          end

          def run
            matching_apps = find_all_matching_apps_or_repos(apps, :heroku, sandbox)
            matching_apps.each do |app|
              ui.info("\n  Config of #{app}\n")
              config = `heroku config -a #{app} --json`
              unless $?.success?
                ui.error("There is a problem in accessing the app with name \"#{app}\" in your account.")
                ui.error("Please check the specified app name and ensure you're authorized to view that app.")
                next
              end
              table = Terminal::Table.new headings: table_columns, rows: filter_config(config)
              ui.success(table)
            end
          end

          private

            def table_columns
              ["Key", "Value"]
            end

            def filter_config(config)
              parsed_config = JSON.parse(config)
              if keys.nil? && required_config_vars_file_path.nil?
                return parsed_config
              end

              required_config = keys || read_json_file(required_config_vars_file_path)
              required_config.map do |key|
                [key, parsed_config[key]]
              end
            end
        end
      end
    end
  end
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
neetob-0.4.34 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.33 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.32 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.31 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.30 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.28 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.27 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.26 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.24 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.23 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.22 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.21 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.20 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.19 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.16 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.15 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.14 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.13 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.12 lib/neetob/cli/heroku/config_vars/list.rb
neetob-0.4.11 lib/neetob/cli/heroku/config_vars/list.rb