Skip to content

Commit

Permalink
Only check if the option value starts with a - when the value is a …
Browse files Browse the repository at this point in the history
…separate arg.

* This will allow for options such as `-p-` (nmap), `--opt=-value`, or `--opt-value`.
  • Loading branch information
postmodern committed Apr 18, 2022
1 parent f2fd56d commit 9440ec9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/command_mapper/option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,15 @@ def emit_option_flag_and_value(argv,value)
else
string = @value.format(value)

if string.start_with?('-')
raise(ValidationError,"option #{@name} formatted value (#{string.inspect}) cannot start with a '-'")
end

if equals?
argv << "#{@flag}=#{string}"
elsif value_in_flag?
argv << "#{@flag}#{string}"
else
if string.start_with?('-')
raise(ValidationError,"option #{@name} formatted value (#{string.inspect}) cannot start with a '-'")
end

argv << @flag << string
end
end
Expand Down

0 comments on commit 9440ec9

Please sign in to comment.