Sha256: f1091f3a640c01351a8ac1d7545db546bb840e193a20a3ae22550387cbeea45c

Contents?: true

Size: 863 Bytes

Versions: 4

Compression:

Stored size: 863 Bytes

Contents

# frozen_string_literal: true

require "forwardable"
require "logger"
require "open3"

module Pragmater
  module CLI
    # A simple delegator for common shell functionality.
    class Helper
      extend Forwardable

      LOGGER = Logger.new STDOUT,
                          formatter: (
                            proc do |_severity, _datetime, _program_name, message|
                              "#{message}\n"
                            end
                          )

      delegate %i[info error fatal debug unknown] => :logger

      def initialize commander: Open3, logger: LOGGER
        @commander = commander
        @logger = logger
      end

      def run command
        commander.capture3 command
      end

      def warn message
        logger.warn message
      end

      private

      attr_reader :commander, :logger
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pragmater-12.1.2 lib/pragmater/cli/helper.rb
pragmater-12.1.1 lib/pragmater/cli/helper.rb
pragmater-12.1.0 lib/pragmater/cli/helper.rb
pragmater-12.0.0 lib/pragmater/cli/helper.rb