Sha256: 1462411972e115286a9c1e66a799b342169c56791265e00f3c5ff17319a89397

Contents?: true

Size: 783 Bytes

Versions: 8

Compression:

Stored size: 783 Bytes

Contents

# frozen_string_literal: true

module Bolt
  class Outputter
    def self.for_format(format, color)
      case format
      when 'human'
        Bolt::Outputter::Human.new(color)
      when 'json'
        Bolt::Outputter::JSON.new(color)
      when nil
        raise "Cannot use outputter before parsing."
      end
    end

    def initialize(color, stream = $stdout)
      @color = color
      @stream = stream
    end

    # This method replaces data types tha have the name 'Data'
    # with the string 'Any'
    # This was a problem when using 'bolt task show <task_name>'
    def replace_data_type(params)
      params.map do |_, v|
        v['type'] = 'Any' if v['type'].to_s == 'Data'
      end
    end
  end
end

require 'bolt/outputter/human'
require 'bolt/outputter/json'

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bolt-0.21.0 lib/bolt/outputter.rb
bolt-0.20.7 lib/bolt/outputter.rb
bolt-0.20.6 lib/bolt/outputter.rb
bolt-0.20.5 lib/bolt/outputter.rb
bolt-0.20.3 lib/bolt/outputter.rb
bolt-0.20.2 lib/bolt/outputter.rb
bolt-0.20.0 lib/bolt/outputter.rb
bolt-0.19.1 lib/bolt/outputter.rb