Sha256: 791e2111bd13f80776340beefb548e32095dc9bc8b84bd33a754d7a79773db45

Contents?: true

Size: 573 Bytes

Versions: 2

Compression:

Stored size: 573 Bytes

Contents

# frozen_string_literal: true

require_relative '../container_command'
require_relative './down'

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
        Down.new.execute
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dru-0.6.0 lib/dru/commands/attach.rb
dru-0.5.2 lib/dru/commands/attach.rb