Sha256: 97b17cecda37542691702e602f07301b797d927b6e490e0d3148f5d9e23c5e38

Contents?: true

Size: 863 Bytes

Versions: 23

Compression:

Stored size: 863 Bytes

Contents

# frozen_string_literal: true

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

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

23 entries across 23 versions & 1 rubygems

Version Path
pragmater-11.5.0 lib/pragmater/cli/helper.rb
pragmater-11.4.0 lib/pragmater/cli/helper.rb
pragmater-11.3.0 lib/pragmater/cli/helper.rb
pragmater-11.2.0 lib/pragmater/cli/helper.rb
pragmater-11.1.0 lib/pragmater/cli/helper.rb
pragmater-11.0.1 lib/pragmater/cli/helper.rb
pragmater-11.0.0 lib/pragmater/cli/helper.rb
pragmater-10.3.1 lib/pragmater/cli/helper.rb
pragmater-10.3.0 lib/pragmater/cli/helper.rb
pragmater-10.2.0 lib/pragmater/cli/helper.rb
pragmater-10.1.0 lib/pragmater/cli/helper.rb
pragmater-10.0.1 lib/pragmater/cli/helper.rb
pragmater-10.0.0 lib/pragmater/cli/helper.rb
pragmater-9.3.0 lib/pragmater/cli/helper.rb
pragmater-9.2.0 lib/pragmater/cli/helper.rb
pragmater-9.1.2 lib/pragmater/cli/helper.rb
pragmater-9.1.1 lib/pragmater/cli/helper.rb
pragmater-9.1.0 lib/pragmater/cli/helper.rb
pragmater-9.0.0 lib/pragmater/cli/helper.rb
pragmater-8.3.0 lib/pragmater/cli/helper.rb