Sha256: 456d2f617b5c6ae02e2f9c5c5a28c3be04fd2c200fb82a523750090a881a0da3

Contents?: true

Size: 820 Bytes

Versions: 5

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

5 entries across 5 versions & 1 rubygems

Version Path
neptuno-1.0.10 lib/neptuno/docker/attach.rb
neptuno-1.0.9 lib/neptuno/docker/attach.rb
neptuno-1.0.8 lib/neptuno/docker/attach.rb
neptuno-1.0.7 lib/neptuno/docker/attach.rb
neptuno-1.0.6 lib/neptuno/docker/attach.rb