Sha256: 947ac9a0890f4b78cbd0b2a9dc1e56084f427c748ff4ee24229d6eda3e3fc75f

Contents?: true

Size: 1.63 KB

Versions: 4

Compression:

Stored size: 1.63 KB

Contents

# typed: strict
# frozen_string_literal: true

module Packwerk
  module Commands
    class BaseCommand
      extend T::Sig
      extend T::Helpers
      abstract!

      @description = T.let("", String)

      class << self
        extend T::Sig

        sig { params(description: T.nilable(String)).returns(String) }
        def description(description = nil)
          if description
            @description = description
          else
            @description
          end
        end
      end

      sig do
        params(
          args: T::Array[String],
          configuration: Configuration,
          out: T.any(StringIO, IO),
          err_out: T.any(StringIO, IO),
          progress_formatter: Formatters::ProgressFormatter,
          offenses_formatter: OffensesFormatter,
        ).void
      end
      def initialize(args, configuration:, out:, err_out:, progress_formatter:, offenses_formatter:)
        @args = args
        @configuration = configuration
        @out = out
        @err_out = err_out
        @progress_formatter = progress_formatter
        @offenses_formatter = offenses_formatter
      end

      sig { abstract.returns(T::Boolean) }
      def run; end

      private

      sig { returns(T::Array[String]) }
      attr_reader :args

      sig { returns(Configuration) }
      attr_reader :configuration

      sig { returns(T.any(StringIO, IO)) }
      attr_reader :out

      sig { returns(T.any(StringIO, IO)) }
      attr_reader :err_out

      sig { returns(Formatters::ProgressFormatter) }
      attr_reader :progress_formatter

      sig { returns(OffensesFormatter) }
      attr_reader :offenses_formatter
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
packwerk-3.2.2 lib/packwerk/commands/base_command.rb
packwerk-3.2.1 lib/packwerk/commands/base_command.rb
packwerk-3.2.0 lib/packwerk/commands/base_command.rb
packwerk-3.1.0 lib/packwerk/commands/base_command.rb