Project

General

Profile

Actions

Feature #16256

closed

A "did you mean" hint for OptionParser

Added by mame (Yusuke Endoh) about 5 years ago. Updated about 5 years ago.

Status:
Closed
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

Updated by mame (Yusuke Endoh) about 5 years ago

  • Status changed from Assigned to Closed

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

Actions

Also available in: Atom PDF

Like0
Like0Like0