Sha256: 43fbd2c2e02d6dc04d3a5fbe3cb5ef3f36dcf332d2a8bb69c622bba328a46d78

Contents?: true

Size: 938 Bytes

Versions: 7

Compression:

Stored size: 938 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module EacRubyUtils
  module Console
    class Configs
      class ReadEntryOptions
        enable_simple_cache
        common_constructor :options

        DEFAULT_VALUES = {
          before_input: nil, bool: false, list: false, noecho: false, noenv: false, noinput: false,
          required: true, validator: nil
        }.freeze

        def [](key)
          values.fetch(key.to_sym)
        end

        def request_input_options
          values.slice(:bool, :list, :noecho)
        end

        private

        def values_uncached
          consumer = options.to_options_consumer
          r = {}
          DEFAULT_VALUES.each do |key, default_value|
            value = consumer.consume(key)
            value = default_value if value.nil?
            r[key] = value
          end
          consumer.validate
          r
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
avm-tools-0.76.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
eac_ruby_utils-0.51.0 lib/eac_ruby_utils/console/configs/read_entry_options.rb
eac_ruby_utils-0.50.0 lib/eac_ruby_utils/console/configs/read_entry_options.rb
ehbrs-tools-0.16.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
avm-tools-0.76.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
eac_ruby_utils-0.49.1 lib/eac_ruby_utils/console/configs/read_entry_options.rb
avm-tools-0.75.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb