Sha256: a72c7036541567d772e525de79117d94d6ed6dcf5a99163e1cf77ea47d47fc13
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
module Onering module CLI require 'yaml' require 'multi_json' @_args = {} def self.connect(cliargs) @_args = cliargs return Onering::API.new({ 'autoconnect' => cliargs[:autoconnect], 'config' => { 'url' => cliargs[:url], 'path' => cliargs[:path], 'source' => cliargs[:source], 'nosslverify' => cliargs[:nosslverify], 'params' => Hash[(cliargs[:param] || []).collect{|i| i.split('=',2) }], 'authentication' => { 'type' => (cliargs[:apikey_given] ? :token : nil), 'keyfile' => (cliargs[:apikey] || cliargs[:sslkey]) }.compact }.compact }.compact) end def self.output(data, format) return nil if @_args[:quiet] Onering::Logger.debug("Outputting data as #{format}:", "Onering::CLI") case format when 'text' if data.is_a?(Hash) data.coalesce.each do |k,v| puts k.to_s+': '+v.to_s end else [*data].each do |d| if d.is_a?(Hash) d.coalesce.each do |k,v| puts k.to_s+': '+v.to_s end else puts d unless d.nil? or d.to_s.empty? end end end when 'json' puts MultiJson.dump(data) when 'yaml' puts YAML.dump(data) else Onering::Logger.error("Unknown output format #{format.inspect}", "Onering::CLI") end nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
onering-client-0.1.2 | lib/onering/cli.rb |