Sha256: 075eb74bbf883b720c8b084717a44b33e4b39275e76b09160083a31a095ebdcf
Contents?: true
Size: 771 Bytes
Versions: 11
Compression:
Stored size: 771 Bytes
Contents
module HammerCLI::Output::Adapter class Json < TreeStructure def print_record(fields, record) result = prepare_collection(fields, [record].flatten(1)) puts JSON.pretty_generate(result.first) end def print_collection(fields, collection) result = prepare_collection(fields, collection) puts JSON.pretty_generate(result) end def print_message(msg, msg_params={}) id = msg_params["id"] || msg_params[:id] name = msg_params["name"] || msg_params[:name] data = { :message => msg.format(msg_params) } data[:id] = id unless id.nil? data[:name] = name unless name.nil? puts JSON.pretty_generate(data) end end HammerCLI::Output::Output.register_adapter(:json, Json) end
Version data entries
11 entries across 11 versions & 1 rubygems