Skip to content

Commit a88497c

Browse files
committed
Allow forcing the return type
1 parent d517d95 commit a88497c

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

ruby/browse.rb

+15-3
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,33 @@ def urlify args={}
3636
return @root + args.map{|k,v| "#{k}=#{CGI::escape(v)}"}.join('&')
3737
end
3838

39-
def jruby_browse args={}
39+
def jruby_browse args={}, forcetype=nil
40+
if forcetype
41+
args['wt'] = forcetype
42+
end
4043
@@desktop.browse(Java::java.net.URI.new(urlify args))
4144
end
4245

43-
def browse args={}
46+
def browse args={}, forcetype = nil
47+
if forcetype
48+
args['wt'] = forcetype
49+
end
4450
Launchy.open urlify(args)
4551
end
4652
end
4753

4854

4955
if __FILE__ == $0
56+
unless ARGV.size > 0
57+
puts "\nusage: ruby browse.rb jsonfile OR"
58+
puts " ruby browse.rb jsonfile [json|csv|standard|xml]"
59+
exit
60+
end
5061
require 'json'
5162
b = Browse.new('http://localhost:8983/solr/select/?')
5263
args = eval(File.open(ARGV[0]).read)
53-
b.browse args
64+
ARGV[1] = 'standard' if ARGV[1] == 'xml'
65+
b.browse args, ARGV[1]
5466
end
5567

5668

0 commit comments

Comments
 (0)