lib/dru/commands/attach.rb in dru-0.6.0 vs lib/dru/commands/attach.rb in dru-1.0.0
- old
+ new
@@ -1,26 +1,30 @@
# frozen_string_literal: true
-require_relative '../container_command'
-require_relative './down'
+require_relative '../command'
module Dru
module Commands
- class Attach < Dru::ContainerCommand
- DOCKER_ATTACH_COMMAND = 'docker attach --detach-keys="ctrl-d"'.freeze
+ class Attach < Dru::Command
+ ATTACH_COMMAND = 'attach'
+ def initialize(service:, options:)
+ @service = service
+ @options = options
+ end
+
def execute(input: $stdin, output: $stdout)
- stop_docker_compose if attach_to_container
+ run_docker_command(ATTACH_COMMAND, detach_keys, container_id)
end
private
- def stop_docker_compose
- Down.new.execute
+ def detach_keys
+ "--detach-keys=#{@options[:detach_keys]}"
end
- def attach_to_container
- system "#{DOCKER_ATTACH_COMMAND} #{container_name_to_id(container)}"
+ def container_id
+ container_name_to_id(@service)
end
end
end
end