Sha256: 0ba7c1f0f9124907c25d70e89fca3d39c7f2561c6fa2e1688e7844870150be0c
Contents?: true
Size: 878 Bytes
Versions: 2
Compression:
Stored size: 878 Bytes
Contents
# encoding: utf-8 module GithubCLI module Formatters class CSV def initialize(response) @response = response end def format case @response when Array render_headers @response.first @response.each_with_index do |item, indx| render_line indx, item $stdout.puts end else render_headers @response render_line 1, @response end end def render_headers(response) output = {} GithubCLI::Util.flatten_hash(response.to_hash, output) puts "Index," + output.keys.join(',') end def render_line(index, item) output = {} GithubCLI::Util.flatten_hash(item.to_hash, output) printf "%d,%s", index, output.values.join(',') end end # CSV end # Formatters end # GithubCLI
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
github_cli-0.3.1 | lib/github_cli/formatters/csv.rb |
github_cli-0.3.0 | lib/github_cli/formatters/csv.rb |