Project

General

Profile

Feature #16256

A "did you mean" hint for OptionParser

Added by mame (Yusuke Endoh) about 1 month ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:95357]

Description

How about showing "did you mean" when a unknown option is passed for OptionParser?

require 'optparse'

OptionParser.new do |opts|
  opts.on("-f", "--foo", "foo") {|v| }
  opts.on("-b", "--bar", "bar") {|v| }
  opts.on("-c", "--baz", "baz") {|v| }
end.parse!
$ ruby test.rb --baa
Traceback (most recent call last):
test.rb:7:in `<main>': invalid option: --baa (OptionParser::InvalidOption)
Did you mean?  baz
               bar

https://github.com/ruby/ruby/pull/2561

History

Updated by mame (Yusuke Endoh) about 1 month ago

  • Status changed from Assigned to Closed

My patch was reviewed by yuki24 (Yuki Nishijima) and nobu (Nobuyoshi Nakada) , and merged. Closing.

Also available in: Atom PDF