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

ruby-changes:74317

From: Nobuyoshi <ko1@a...>
Date: Wed, 2 Nov 2022 13:30:00 +0900 (JST)
Subject: [ruby-changes:74317] ac06951c31 (master): file2lastrev.rb: separate options for `Output` and `VPath`

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

From ac06951c31c59781951a70788e4b0de2aa3d481c Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 2 Nov 2022 11:37:54 +0900
Subject: file2lastrev.rb: separate options for `Output` and `VPath`

So the `--srcdir` option in this file can override the same option in
`VPath`.
---
 tool/file2lastrev.rb | 3 ++-
 tool/lib/output.rb   | 1 +
 tool/lib/vpath.rb    | 5 +++++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb
index db9e6fec42..a2b639a426 100755
--- a/tool/file2lastrev.rb
+++ b/tool/file2lastrev.rb
@@ -28,11 +28,13 @@ vcs = nil https://github.com/ruby/ruby/blob/trunk/tool/file2lastrev.rb#L28
 OptionParser.new {|opts|
   opts.banner << " paths..."
   vcs_options = VCS.define_options(opts)
+  opts.new {@output.def_options(opts)}
   srcdir = nil
   opts.new
   opts.on("--srcdir=PATH", "use PATH as source directory") do |path|
     abort "#{File.basename(Program)}: srcdir is already set" if srcdir
     srcdir = path
+    @output.vpath.add(srcdir)
   end
   opts.on("--changed", "changed rev") do
     self.format = :changed
@@ -53,7 +55,6 @@ OptionParser.new {|opts| https://github.com/ruby/ruby/blob/trunk/tool/file2lastrev.rb#L55
   opts.on("-q", "--suppress_not_found") do
     @suppress_not_found = true
   end
-  @output.def_options(opts)
   opts.order! rescue abort "#{File.basename(Program)}: #{$!}\n#{opts}"
   begin
     vcs = VCS.detect(srcdir || ".", vcs_options, opts.new)
diff --git a/tool/lib/output.rb b/tool/lib/output.rb
index 5e0e878322..584be76974 100644
--- a/tool/lib/output.rb
+++ b/tool/lib/output.rb
@@ -10,6 +10,7 @@ class Output https://github.com/ruby/ruby/blob/trunk/tool/lib/output.rb#L10
   end
 
   def def_options(opt)
+    opt.separator("  Output common options:")
     opt.on('-o', '--output=PATH') {|v| @path = v}
     opt.on('-t', '--timestamp[=PATH]') {|v| @timestamp = v || true}
     opt.on('-c', '--[no-]if-change') {|v| @ifchange = v}
diff --git a/tool/lib/vpath.rb b/tool/lib/vpath.rb
index a52f840c30..fa819f3242 100644
--- a/tool/lib/vpath.rb
+++ b/tool/lib/vpath.rb
@@ -53,6 +53,7 @@ class VPath https://github.com/ruby/ruby/blob/trunk/tool/lib/vpath.rb#L53
   end
 
   def def_options(opt)
+    opt.separator("  VPath common options:")
     opt.on("-I", "--srcdir=DIR", "add a directory to search path") {|dir|
       @additional << dir
     }
@@ -80,6 +81,10 @@ class VPath https://github.com/ruby/ruby/blob/trunk/tool/lib/vpath.rb#L81
     @list
   end
 
+  def add(path)
+    @additional << path
+  end
+
   def strip(path)
     prefix = list.map {|dir| Regexp.quote(dir)}
     path.sub(/\A#{prefix.join('|')}(?:\/|\z)/, '')
-- 
cgit v1.2.3


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

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