lib/oci8_simple/cli.rb in oci8_simple-0.6.1 vs lib/oci8_simple/cli.rb in oci8_simple-0.7.0

- old
+ new

@@ -12,16 +12,20 @@ def initialize(env=nil) self.env = env end - def run(sql) - format(client.run(sql)) + def run(sql, options={}) + format(client.run(sql, options), options) end - def format(arr) - arr.map{|row| row.join(", ")}.join("\n") + def format(arr, options) + if(options[:hash]) + arr.map{|row| row.map{|k,v| "#{k}: #{v}"}.join("\n")}.join("\n\n") + else + arr.map{|row| row.join(", ")}.join("\n") + end end def client @client ||= Client.new(env) end @@ -33,10 +37,10 @@ def self.run_from_argv o = parse_options(self.usage) if(ARGV[0].nil?) puts o else - puts self.new(ARGV[1]).run(ARGV[0]) + puts self.new(ARGV[1]).run(ARGV[0], @options) end end end end \ No newline at end of file