Skip to content

Commit 1579377

Browse files
committed
-v prints version and do something
Without this patch, `rdbg -v target.rb` prints version and terminates the process. With this pach, `-v` prints version and starts debugging for `target.rb`. If no filename is given, terminates the process.
1 parent a8026a6 commit 1579377

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/debug/config.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ def self.parse_argv argv
265265
require 'optparse'
266266
require_relative 'version'
267267

268+
have_shown_version = false
269+
268270
opt = OptionParser.new do |o|
269271
o.banner = "#{$0} [options] -- [debuggee options]"
270272
o.separator ''
@@ -372,6 +374,16 @@ def self.parse_argv argv
372374
o.separator ''
373375
o.separator 'Other options:'
374376

377+
o.on('-v', 'Show version number') do
378+
puts o.ver
379+
have_shown_version = true
380+
end
381+
382+
o.on('--version', 'Show version number and exit') do
383+
puts o.ver
384+
exit
385+
end
386+
375387
o.on("-h", "--help", "Print help") do
376388
puts o
377389
exit
@@ -395,6 +407,14 @@ def self.parse_argv argv
395407

396408
opt.parse!(argv)
397409

410+
if argv.empty?
411+
case
412+
when have_shown_version && config[:mode] == :start
413+
pp config
414+
exit
415+
end
416+
end
417+
398418
config
399419
end
400420

0 commit comments

Comments
 (0)