Module: Facter::OptionsValidator
- Defined in:
- lib/framework/core/options/options_validator.rb
Constant Summary collapse
- INVALID_PAIRS_RULES =
{ '--color' => '--no-color', '--json' => ['--no-json', '-y', '--yaml', '--hocon'], '--yaml' => ['--no-yaml', '-j', '--hocon'], '--hocon' => '--no-hocon', '-j' => ['--no-json', '--hocon'], '-y' => ['--no-yaml', '-j', '--hocon'], '--puppet' => ['--no-puppet', '--no-ruby', '--no-custom-facts'], '-p' => ['--no-puppet', '--no-ruby', '--no-custom-facts'], '--no-external-facts' => '--external-dir', '--custom-dir' => ['--no-custom-facts', '--no-ruby'] }.freeze
- DUPLICATED_OPTIONS_RULES =
{ '-j' => '--json', '-y' => '--yaml', '-p' => '--puppet', '-h' => '--help', '-v' => '--version', '-l' => '--log-level', '-d' => '--debug', '-c' => '--config' }.freeze
- LOG_LEVEL =
%i[none trace debug info warn error fatal].freeze
Class Method Summary collapse
Class Method Details
.validate(options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/framework/core/options/options_validator.rb', line 20 def self.validate() DUPLICATED_OPTIONS_RULES.each do |key, value| if .include?(key) && .include?(value) write_error_and_exit("option #{value} cannot be specified more than once.") end end INVALID_PAIRS_RULES.each do |key, value| common_values = [value].flatten & if .include?(key) && common_values.any? write_error_and_exit("#{key} and #{common_values.first} options conflict: please specify only one.") end end end |