lib/onering/cli.rb in onering-client-0.1.2 vs lib/onering/cli.rb in onering-client-0.1.3

- old
+ new

@@ -24,19 +24,24 @@ }.compact) end def self.output(data, format) return nil if @_args[:quiet] + return nil if data.nil? Onering::Logger.debug("Outputting data as #{format}:", "Onering::CLI") case format - when 'text' + when 'text', 'txt' if data.is_a?(Hash) data.coalesce.each do |k,v| puts k.to_s+': '+v.to_s end + + elsif data.is_a?(Array) and data.first.is_a?(Array) + puts data.collect{|i| i.map(&:to_s).join(@_args.get(:separator, "\t")) }.sort.join("\n") + else [*data].each do |d| if d.is_a?(Hash) d.coalesce.each do |k,v| puts k.to_s+': '+v.to_s @@ -46,18 +51,18 @@ end end end when 'json' - puts MultiJson.dump(data) + puts MultiJson.dump(data, :pretty => true) when 'yaml' puts YAML.dump(data) else Onering::Logger.error("Unknown output format #{format.inspect}", "Onering::CLI") end - nil + return nil end end end