dru 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecaeff419166c955c4db31d00e6f8ec4af1a51d66d8b07adb4ef9a4313e489f4
4
- data.tar.gz: d271501bff0d3d7f3d5acdb7af9d3640bd0ee49ab513453e5f47e6db77ac32c7
3
+ metadata.gz: def2420df9cee2ed5c5a4a33c606ad27ba20fd72a84c51a93b10aa8ad8b662c8
4
+ data.tar.gz: c9be5d2ddb85b0bfb1ab51d41632441a1918a079ba38adfcec42bb5736273e79
5
5
  SHA512:
6
- metadata.gz: 841e2324220cdce42b0670ef357dc8d17e3a1392f43bc5ea55fd14fa7589ed79d6708859f5dd90c7400c71204f70c70b4901001b1caf267f9766c2df6800bd6b
7
- data.tar.gz: d2fbe9d4e1678fd0fb31a59263e364a119672fce16b9505d0b87f5d23e39596b06ea51fefdbd8cc9df5458b0418ddbcf7bb1f12833090549570c95c921fe037b
6
+ metadata.gz: 4ae0153d0c05c59cfc36f3dd22fdc13961fb05e4fa3c5846dd919325a1c3df3f1e7363c35450d5404d2845839239789f098e1d6501cb5676baf7ebe93212e15a
7
+ data.tar.gz: abf9ce5c427623e592469666d8ffcf8b3d15c22a44c9518d5745dee9b01c902775ae169cab9934185e5b4e2c1349243db60c2dd0200dd10e828218e8dcd679d4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dru (0.3.1)
4
+ dru (0.4.0)
5
5
  pastel (~> 0.7.2)
6
6
  thor (~> 0.20.0)
7
7
  tty-color (~> 0.4.2)
data/lib/dru/cli.rb CHANGED
@@ -18,6 +18,20 @@ module Dru
18
18
  end
19
19
  map %w(--version -v) => :version
20
20
 
21
+ desc 'attach', 'Attach local standard input, output, and error streams to a running container'
22
+ method_option :help, aliases: '-h', type: :boolean,
23
+ desc: 'Display usage information'
24
+ method_option :container, aliases: '-c', type: :string, default: 'app',
25
+ desc: 'Container name'
26
+ def attach(*)
27
+ if options[:help]
28
+ invoke :help, ['attach']
29
+ else
30
+ require_relative 'commands/attach'
31
+ Dru::Commands::Attach.new(options: options).execute
32
+ end
33
+ end
34
+
21
35
  desc 'exec', 'Execute a command in a running container.'
22
36
  method_option :help, aliases: '-h', type: :boolean,
23
37
  desc: 'Display usage information'
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../container_command'
4
+
5
+ module Dru
6
+ module Commands
7
+ class Attach < Dru::ContainerCommand
8
+ DOCKER_ATTACH_COMMAND = 'docker attach --detach-keys="ctrl-d"'.freeze
9
+
10
+ def execute(input: $stdin, output: $stdout)
11
+ stop_docker_compose if attach_to_container
12
+ end
13
+
14
+ private
15
+
16
+ def stop_docker_compose
17
+ run_docker_compose_command('down')
18
+ end
19
+
20
+ def attach_to_container
21
+ system "#{DOCKER_ATTACH_COMMAND} #{container_name_to_id(container)}"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -4,7 +4,7 @@ require_relative './command'
4
4
 
5
5
  module Dru
6
6
  class ContainerCommand < Command
7
- def initialize(command:, options:)
7
+ def initialize(command: nil, options:)
8
8
  raise MissingContainerError unless options[:container]
9
9
 
10
10
  @options = options
@@ -0,0 +1 @@
1
+ #
data/lib/dru/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dru
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Rimondi
@@ -364,12 +364,14 @@ files:
364
364
  - lib/dru/cli.rb
365
365
  - lib/dru/command.rb
366
366
  - lib/dru/commands/.gitkeep
367
+ - lib/dru/commands/attach.rb
367
368
  - lib/dru/commands/exec.rb
368
369
  - lib/dru/commands/runner.rb
369
370
  - lib/dru/commands/up.rb
370
371
  - lib/dru/config.rb
371
372
  - lib/dru/container_command.rb
372
373
  - lib/dru/templates/.gitkeep
374
+ - lib/dru/templates/attach/.gitkeep
373
375
  - lib/dru/templates/exec/.gitkeep
374
376
  - lib/dru/templates/runner/.gitkeep
375
377
  - lib/dru/templates/up/.gitkeep