Sha256: b7ee1836aceb1a786785216e4e3a685ab486c723273cf9fc0b98334ea64c29c4
Contents?: true
Size: 1.13 KB
Versions: 9
Compression:
Stored size: 1.13 KB
Contents
# encoding: utf-8 module GithubCLI # This is the main entry point for formatting output. # It delegates to other objects like Formatter::Table # to perform actual rendering. class Formatter attr_reader :response, :format def initialize(response, options={}) @response = response @format = options[:format] end def render_output render_status Terminal.paged_output determine_output_formatter end def determine_output_formatter case format.to_s when 'table', /table:v.*/, /table:h.*/ formatter = Formatters::Table.new(response, :transform => format.to_s.split(':').last ) formatter.format when 'csv' formatter = Formatters::CSV.new(response) formatter.format when 'json' 'json output' else raise UnknownFormatError, format end end # Render status code def render_status if response.respond_to? :status Terminal.line "Response Status: #{response.status}\n" Terminal.newline end end end # Formatter end # GithubCLi
Version data entries
9 entries across 9 versions & 1 rubygems