Sha256: 636369b8d982a09fab33f2e27af5d01c0de3451d7b6b87d5cd8484614a15d1f5

Contents?: true

Size: 1.07 KB

Versions: 7

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

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

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

    def indent(indent, string)
      indent = ' ' * indent
      string.gsub(/^/, indent.to_s)
    end

    def print_message
      raise NotImplementedError, "print_message() must be implemented by the outputter class"
    end

    def print_error
      raise NotImplementedError, "print_error() must be implemented by the outputter class"
    end
  end
end

require 'bolt/outputter/human'
require 'bolt/outputter/json'
require 'bolt/outputter/logger'
require 'bolt/outputter/rainbow'

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bolt-2.37.0 lib/bolt/outputter.rb
bolt-2.36.0 lib/bolt/outputter.rb
bolt-2.35.0 lib/bolt/outputter.rb
bolt-2.34.0 lib/bolt/outputter.rb
bolt-2.33.2 lib/bolt/outputter.rb
bolt-2.33.1 lib/bolt/outputter.rb
bolt-2.32.0 lib/bolt/outputter.rb