Sha256: c15ef85e2c709710d81e4f278fd447e6b7a740d3692a833bc2dc5fcb1725833c

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

# frozen_string_literal: true

require 'lino'

module RubyLeiningen
  module Commands
    class Base
      attr_reader :binary

      def initialize(opts = {})
        @binary = opts[:binary] || RubyLeiningen.configuration.binary
      end

      def stdin
        nil
      end

      def stdout
        $stdout
      end

      def stderr
        $stderr
      end

      def execute(opts = {})
        do_before(opts)
        configure_command(instantiate_builder, opts)
          .build
          .execute(stdin:, stdout:, stderr:)
        do_after(opts)
      end

      def instantiate_builder
        Lino::CommandLineBuilder
          .for_command(binary)
      end

      def do_before(opts); end

      def configure_command(builder, _opts)
        builder
      end

      def do_after(opts); end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby_leiningen-0.28.0.pre.5 lib/ruby_leiningen/commands/base.rb