Sha256: 0932ab73e12e4909eb8cae26c571338fe5780467722db68a5d90f2dc350314da

Contents?: true

Size: 820 Bytes

Versions: 4

Compression:

Stored size: 820 Bytes

Contents

# frozen_string_literal: true

module Neptuno
  module Docker
    class Attach < Neptuno::CLI::Base
      include ::Neptuno::TTY::Config
      desc "Docker: Attach to a container's command"

      option :up, type: :boolean, default: false, desc: "Try to start containers before connecting"

      def call(**options)
        command_service_to("attach", service_as_args: options[:args].first) do |service, project|
          system("cd #{neptuno_path} && docker compose up -d #{service}") if options.fetch(:up)
          success = system("cd #{neptuno_path} && docker attach #{project}_#{service}_1")
          unless success
            puts "Trying #{project}-#{services.first}-1"
            system("cd #{neptuno_path} && docker attach #{project}-#{service}-1")
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
neptuno-1.5.0 lib/neptuno/docker/attach.rb
neptuno-1.4.10 lib/neptuno/docker/attach.rb
neptuno-1.2.1 lib/neptuno/docker/attach.rb
neptuno-1.2.0 lib/neptuno/docker/attach.rb