Reputation: 4199
I only have 1 possible option and it is parsed as following:
def parse_options
options = {}
options[:markdown] = false
OptionParser.new do |opts|
opts.on('-md', '--markdown', 'Use Markdown Syntax') do
options[:markdown] = true
end
end.parse!
end
As you can see the option doesn't require any argument. What I find even stranger is this works:
command -md
but this throws the exception:
command --markdown
in `parse_options': missing argument: --markdown (OptionParser::MissingArgument)
Any ideas? I read the doc and multiple examples but can't figure it out.
Upvotes: 2
Views: 2405
Reputation: 1132
You can't use a two letter switch like that. With
opts.on('-m', '--markdown', 'Use Markdown Syntax') do
it works fine. See Short style switch under OptionParser documentation
Upvotes: 4