Permalink
Browse files

added raw flag

  • Loading branch information...
1 parent b265285 commit 869c2019ec03f73b896bd689c687043916f9df8f @kornypoet kornypoet committed Feb 15, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 bin/estool
View
10 bin/estool
@@ -36,6 +36,7 @@ EOS
options.index = "_all"
options.segments = 3
options.query = "foo"
+ options.raw = false
options.usage = opts
opts.on('-c', '--host HOSTNAME', 'Connect to ElasticSearch on HOSTNAME', 'Defaults to localhost') do |host|
@@ -54,6 +55,10 @@ EOS
options.segments = num
end
+ opts.on('-r','--raw', 'Return raw JSON for parsing by another program') do
+ options.raw = true
+ end
+
opts.on('-q', '--query STRING', 'Query INDEX with STRING.', 'Defaults to foo. Use with <search>') do |str|
options.query = str
end
@@ -77,8 +82,9 @@ class ESTool
end
def display cmd
- result = self.send(cmd.to_sym)
- puts JSON.pretty_generate(result, :max_nesting => 100)
+ result = self.send(cmd.to_sym)
+ display = options.raw ? result.to_json : JSON.pretty_generate(result, :max_nesting => 100)
+ puts display
end
def status() shell_response(File.join(options.index, "_status?")) ; end

0 comments on commit 869c201

Please sign in to comment.