OptionParser short flag includes space in argument?

Has OptionParser always included the space when using short flag with argument?

require "option_parser"
argv = ["-a value", "--aaa=value", "-avalue"]
parser = OptionParser.parse(argv) do |p|
  p.on("-a VALUE", "--aaa=VALUE", "set a") { |v| puts "'#{v}'" }
end

outputs:

' value'
'value'
'value'

It’s not clear from the docs that it is included (from the docs I’d expect it to be included).

Try this:

argv = ["-a", "value", "--aaa=value", "-avalue"]

Your original value is if like you passed something like

program "-a value" -aaa=value -avalue
3 Likes

Haha, of course. Thanks!