bin/web_grep in web_grep-1.0.3 vs bin/web_grep in web_grep-1.1.0
- old
+ new
@@ -5,12 +5,11 @@
require 'web_grep'
options = {}
OptionParser.new do |opt|
opt.banner = "Usage:\n web_grep WORD WEB_PAGE [OPTIONS]"
- opt.separator ''
- opt.separator 'Options'
+ opt.separator "\nOptions"
opt.on('-w', '--word [word]', String, 'Searcheble word or RegExp') do |word|
options[:word] = word
end
@@ -24,14 +23,22 @@
opt.on('-q', '--quite', 'Show only xpaths') do |q|
options[:quite] = q
end
- opt.on('-c', '--only-count', 'Show only count') do |c|
+ opt.on('-c', '--count', 'Show only count') do |c|
options[:only_count] = c
end
+ opt.on('-x', '--xpath', 'Show xpaths to founded') do |x|
+ options[:xpath] = x
+ end
+
+ opt.on('-s', '--css', 'Show css paths to founded') do |s|
+ options[:css] = s
+ end
+
opt.on_tail('-v', '--version', 'Show version') do
puts WebGrep::VERSION
exit
end
@@ -47,7 +54,11 @@
url: options[:url ] || ARGV[1],
file: options[:file],
quite: options[:quite]
).grep!
-puts greped if !options[:only_count]
+greped.each do |l|
+ puts "\033[32;1m" + "CSS path: #{l.css_path}" if options[:css]
+ puts "\033[32;1m" + "XPath: #{l.path}" if options[:xpath]
+ puts "\033[0m" + "Matched content: #{l.content}" unless options[:quite]
+end unless options[:only_count]
puts "#{"\033[32;1m"}Found #{greped.count}#{"\033[0m"}"
\ No newline at end of file