Class: CLIOptions
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- CLIOptions
- Defined in:
- lib/hyrum.rb
Class Method Summary collapse
Class Method Details
.build_and_validate(input) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/hyrum.rb', line 44 def self.build_and_validate(input) # apply defaults and coercions = new(input) # validate the options contract_result = CLIOptionsContract.new.call(.to_h) if contract_result.errors.any? = contract_result.errors.to_h.map do |key, errors| error_text = errors.is_a?(Array) ? errors.join(', ') : errors "Error with #{key}: #{error_text}" end raise Hyrum::ScriptOptionsError, .join("\n") end contract_result end |