[前][次][番号順一覧][スレッド一覧]

ruby-changes:58312

From: Yusuke <ko1@a...>
Date: Fri, 18 Oct 2019 17:54:19 +0900 (JST)
Subject: [ruby-changes:58312] ddad1fb229 (master): NEWS: Mention that optparse now supports did_you_mean for unknown option

https://git.ruby-lang.org/ruby.git/commit/?id=ddad1fb229

From ddad1fb229421be3dc4b0a3031cb410b62a233a9 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Fri, 18 Oct 2019 17:53:17 +0900
Subject: NEWS: Mention that optparse now supports did_you_mean for unknown
 option


diff --git a/NEWS b/NEWS
index aadb122..5d10fec 100644
--- a/NEWS
+++ b/NEWS
@@ -401,6 +401,23 @@ open-uri:: https://github.com/ruby/ruby/blob/trunk/NEWS#L401
   * The default charset of text/* media type is UTF-8 instead of
     ISO-8859-1.  [Bug #15933]
 
+OptionParser::
+
+  * Now show "Did you mean?" for unknown option.  [Feature #16256]
+
+    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
+
 Pathname::
 
   * Delegates 3 arguments from Pathname.glob to Dir.glob to
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]