Sha256: a8612d7db3e7c709cb4ccb58e2740e3de4df156a62a3bcb08d0e8e0f70c56916

Contents?: true

Size: 832 Bytes

Versions: 10

Compression:

Stored size: 832 Bytes

Contents

# frozen_string_literal: true

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

    def initialize(color, trace, stream = $stdout)
      @color = color
      @trace = trace
      @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

10 entries across 10 versions & 1 rubygems

Version Path
bolt-0.23.0 lib/bolt/outputter.rb
bolt-0.22.0 lib/bolt/outputter.rb
bolt-0.21.8 lib/bolt/outputter.rb
bolt-0.21.7 lib/bolt/outputter.rb
bolt-0.21.6 lib/bolt/outputter.rb
bolt-0.21.5 lib/bolt/outputter.rb
bolt-0.21.4 lib/bolt/outputter.rb
bolt-0.21.3 lib/bolt/outputter.rb
bolt-0.21.2 lib/bolt/outputter.rb
bolt-0.21.1 lib/bolt/outputter.rb