Sha256: 4c8c49fedb3b127b71079da1cf94184faf1d9c9a7e71113cd62b33dc9b3a337a

Contents?: true

Size: 565 Bytes

Versions: 3

Compression:

Stored size: 565 Bytes

Contents

# frozen_string_literal: true

require_relative '../container_command'

module Dru
  module Commands
    class Attach < Dru::ContainerCommand
      DOCKER_ATTACH_COMMAND = 'docker attach --detach-keys="ctrl-d"'.freeze

      def execute(input: $stdin, output: $stdout)
        stop_docker_compose if attach_to_container
      end

      private

      def stop_docker_compose
        run_docker_compose_command('down')
      end

      def attach_to_container
        system "#{DOCKER_ATTACH_COMMAND} #{container_name_to_id(container)}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dru-0.5.1 lib/dru/commands/attach.rb
dru-0.5.0 lib/dru/commands/attach.rb
dru-0.4.0 lib/dru/commands/attach.rb