bin/kds in kdwatch-0.5.5 vs bin/kds in kdwatch-0.5.6

- old
+ new

@@ -1,16 +1,18 @@ #!/usr/bin/env ruby require 'socket' require 'uri' require 'open-uri' require 'optparse' +require 'optparse/uri' KDWATCH_VERSION=Gem.loaded_specs["kdwatch"].version rescue "unknown-version" loport = 7991 hiport = 7999 match = nil +uri = URI.parse("http://127.0.0.1") op = OptionParser.new do |opts| opts.banner = <<BANNER Usage: kds [options] [match...] Version: #{KDWATCH_VERSION} (from kdwatch) @@ -21,24 +23,34 @@ end opts.on("-h", "--help", "Show option summary and exit") do |v| puts opts exit end + opts.on("-uURI", "--uri=URI", URI, "Use base URI (#{uri})") do |v| + uri = v + unless uri.host # questionable convenience feature + uri.host = uri.path #.sub(/\A([A-Za-z0-9:]+)\z/) {"[#{$1}]"} + uri.path = "" + end + uri.scheme ||= "http" + end opts.on("-fNUM", "--from=NUM", Integer, "Search from port number (#{loport})") do |v| loport = v end opts.on("-tNUM", "--to=NUM", Integer, "Search to port number (#{hiport})") do |v| hiport = v + hiport += 8000 if hiport < loport # questionable convenience feature end end op.parse! if ARGV.size != 0 match = ARGV.join(" ") end (loport..hiport).each do |p| - url = "http://127.0.0.1:#{p}" + uri.port = p + url = uri.to_s URI(url).open do |f| s = f.readpartial(40000) sc = s.scan(/id="title".*?<|Internal server error/) sc.each do |scl| scl.sub!(/id="title">/, "")