Sha256: 48afd396ea0f2d39bbfb74283bd243aec379fc9e339bb3be32257263009ec1e8

Contents?: true

Size: 1.45 KB

Versions: 20

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

module Facter
  class Options
    class << self
      def cli?
        OptionStore.cli
      end

      def get
        OptionStore.all
      end

      def [](key)
        OptionStore.send(key.to_sym)
      end

      def []=(key, value)
        OptionStore.send("#{key}=".to_sym, value)
      end

      def custom_dir?
        OptionStore.custom_dir && OptionStore.custom_facts
      end

      def custom_dir
        [OptionStore.custom_dir].flatten
      end

      def external_dir?
        OptionStore.external_dir && OptionStore.external_facts
      end

      def external_dir
        OptionStore.external_dir
      end

      def init
        OptionStore.cli = false
        ConfigFileOptions.init
        store(ConfigFileOptions.get)
      end

      def init_from_cli(cli_options = {}, user_query = nil)
        Facter::OptionStore.cli = true
        Facter::OptionStore.show_legacy = false
        Facter::OptionStore.user_query = user_query
        Facter::OptionStore.trace = cli_options[:trace]
        OptionStore.set(:config, cli_options[:config])
        ConfigFileOptions.init(cli_options[:config])
        store(ConfigFileOptions.get)
        store(cli_options)

        Facter::OptionsValidator.validate_configs(get)
      end

      def store(options)
        options.each do |key, value|
          value = '' if key == 'log_level' && value == 'log_level'
          OptionStore.set(key, value)
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
facter-4.0.51 lib/facter/framework/core/options.rb
facter-4.0.50 lib/facter/framework/core/options.rb
facter-4.0.49 lib/facter/framework/core/options.rb
facter-4.0.48 lib/facter/framework/core/options.rb
facter-4.0.47 lib/facter/framework/core/options.rb
facter-4.0.46 lib/facter/framework/core/options.rb
facter-4.0.44 lib/facter/framework/core/options.rb
facter-4.0.43 lib/facter/framework/core/options.rb
facter-4.0.42 lib/facter/framework/core/options.rb
facter-4.0.41 lib/facter/framework/core/options.rb
facter-4.0.40 lib/facter/framework/core/options.rb
facter-4.0.39 lib/facter/framework/core/options.rb
facter-4.0.38 lib/facter/framework/core/options.rb
facter-4.0.37 lib/facter/framework/core/options.rb
facter-4.0.36 lib/facter/framework/core/options.rb
facter-4.0.35 lib/facter/framework/core/options.rb
facter-4.0.34 lib/facter/framework/core/options.rb
facter-4.0.33 lib/facter/framework/core/options.rb
facter-4.0.32 lib/facter/framework/core/options.rb
facter-4.0.31 lib/facter/framework/core/options.rb