Module: Dry::CLI::Parser
- Defined in:
- lib/allure_report_publisher/lib/parser.rb
Overview
Parser overload to support loading all options from environment variables
Defined Under Namespace
Classes: InvalidEnvValue
Constant Summary collapse
- ENV_VAR_PREFIX =
"ALLURE_".freeze
Class Method Summary collapse
Class Method Details
.call(command, arguments, prog_name) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/allure_report_publisher/lib/parser.rb', line 11 def call(command, arguments, prog_name) original_arguments = arguments.dup = {} OptionParser.new do |opts| command..each do |option| opts.on(*option.) do |value| [option.name.to_sym] = value end end opts.on_tail("-h", "--help") do return Result.help end end.parse!(arguments) = command .default_params .merge((command., )) parse_required_params(command, arguments, prog_name, ) rescue ::OptionParser::ParseError, InvalidEnvValue => e return Result.failure(e.) if e.is_a?(InvalidEnvValue) Result.failure("ERROR: \"#{prog_name}\" was called with arguments \"#{original_arguments.join(' ')}\"") end |