dru 0.5.2 → 0.6.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: df4335d16710597624a2442e9d1b593a992ed716063a41dbc5811ed98e0d0980
4
- data.tar.gz: 9a175fb8feb8dc086cd01a9d08075e469e890b983d68ace2f406395807face0b
3
+ metadata.gz: f75222fea85c8eefdd69ea93f802d91ebee51005ba4c1101ced62c4982743b2b
4
+ data.tar.gz: 39838ee39b7a874223b4b7986ff4574fc22067e1944a50c2d3169843a36d781c
5
5
  SHA512:
6
- metadata.gz: fc242d06d74627299a75d15a09c57cd520685d09c4cad2b13ac087375a81722aa3ae5e642f90625082acf20a1f037fc0e52fa3d189666b8b151b270cd7cc5be3
7
- data.tar.gz: '086e53ab1e4c6cbb4487a8f27c957df719f01611bb8e981748a658e71b310ea2b9f29d9e7d95611471d66482f9cf9a0d40d7237bca9975ca41281df21bdcbb60'
6
+ metadata.gz: '09f30684009c75b7d32b458e14de955d950bb9113653c843d2b22a895ae4ecde977cb6a5551a0a568d307f6eea3e7526a1049c311f199c72609b4beaa0dfd366'
7
+ data.tar.gz: b9b79033ee1d5e9624e59fd4fb056c7a05f0144d1f96681e9d5624203cf52ca1bb6e91de969d98465d01af7d01c6909bb56eb7aa2fda74df940747be00b96957
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dru (0.5.2)
4
+ dru (0.6.0)
5
5
  pastel (~> 0.7.2)
6
6
  thor (~> 0.20.0)
7
7
  tty-color (~> 0.4.2)
data/exe/dru CHANGED
@@ -11,7 +11,7 @@ Signal.trap('INT') do
11
11
  end
12
12
 
13
13
  begin
14
- Dru::CLI.start
14
+ Dru::CLI.start(Dru::Argv.new.parse)
15
15
  rescue Dru::CLI::Error => err
16
16
  puts "ERROR: #{err.message}"
17
17
  exit 1
data/lib/dru.rb CHANGED
@@ -1,8 +1,13 @@
1
+ require "dru/argv"
1
2
  require "dru/config"
2
3
  require "dru/cli"
3
4
 
4
5
  module Dru
5
- DRUCONFIG = File.expand_path('~/.druconfig')
6
+ DRUCONFIG = File.expand_path('~/.druconfig')
7
+ DOCKER_COMPOSE_COMMAND = 'docker-compose'.freeze
8
+ DOCKER_COMPOSE_COMMANDS = %w[build bundle config create events images kill
9
+ logs pause port ps pull push restart rm scale
10
+ start stop top unpause]
6
11
 
7
12
  def self.config
8
13
  Config.instance.tap { |instance| instance.config_file_path = DRUCONFIG }
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dru
4
+ class Argv
5
+ attr_reader :argv
6
+
7
+ def initialize(argv = ARGV)
8
+ @argv = argv
9
+ end
10
+
11
+ def parse
12
+ return argv unless docker_compose_command_index
13
+
14
+ argv.dup.insert(docker_compose_command_index, Thor::Options::OPTS_END)
15
+ end
16
+
17
+ private
18
+
19
+ def docker_compose_command_index
20
+ argv.index { |arg| docker_compose_command?(arg) }
21
+ end
22
+
23
+ def docker_compose_command?(arg)
24
+ Dru::DOCKER_COMPOSE_COMMANDS.include?(arg)
25
+ end
26
+ end
27
+ end
@@ -11,13 +11,45 @@ module Dru
11
11
  # Error raised by this runner
12
12
  Error = Class.new(StandardError)
13
13
 
14
+ class_option :environment, aliases: '-e', type: :string,
15
+ desc: 'Environment'
16
+
17
+ default_command :docker_compose
18
+
19
+ def self.help(shell, subcommand = false)
20
+ shell.say `#{DOCKER_COMPOSE_COMMAND} help`
21
+ shell.say
22
+
23
+ shell.say <<-OUT
24
+ These Docker-Compose commands are provided by Dru:
25
+
26
+ Usage:
27
+ dru [-e ENV] [docker-compose-options] [COMMAND] [ARGS...]
28
+ dru -h|--help
29
+
30
+ OUT
31
+
32
+ super
33
+ end
34
+
14
35
  desc 'version', 'dru version'
15
36
  def version
16
37
  require_relative 'version'
17
- puts "v#{Dru::VERSION}"
38
+ shell.say "dru version: #{Dru::VERSION}"
39
+ shell.say `#{DOCKER_COMPOSE_COMMAND} version`
18
40
  end
19
41
  map %w(--version -v) => :version
20
42
 
43
+ desc 'docker-compose', 'Run docker-compose', hide: true
44
+ def docker_compose(*command)
45
+ if command.empty?
46
+ invoke :help
47
+ else
48
+ require_relative 'commands/docker_compose'
49
+ Dru::Commands::DockerCompose.new(command: command, options: options).execute
50
+ end
51
+ end
52
+
21
53
  desc 'down', 'Stops containers and removes containers, networks, volumes, and images created by `up`.'
22
54
  method_option :help, aliases: '-h', type: :boolean,
23
55
  desc: 'Display usage information'
@@ -49,8 +81,6 @@ module Dru
49
81
  desc: 'Display usage information'
50
82
  method_option :container, aliases: '-c', type: :string, default: 'app',
51
83
  desc: 'Container name'
52
- method_option :environment, aliases: '-e', type: :string,
53
- desc: 'Environment'
54
84
  def exec(*command)
55
85
  if options[:help]
56
86
  invoke :help, ['exec']
@@ -79,8 +109,6 @@ module Dru
79
109
  desc: 'Display usage information'
80
110
  method_option :container, aliases: '-c', type: :string, default: 'app',
81
111
  desc: 'Container name'
82
- method_option :environment, aliases: '-e', type: :string,
83
- desc: 'Environment'
84
112
  def runner(*command)
85
113
  if options[:help]
86
114
  invoke :help, ['runner']
@@ -12,8 +12,6 @@ module Dru
12
12
  end
13
13
  end
14
14
 
15
- DOCKER_COMPOSE_COMMAND = 'docker-compose'.freeze
16
-
17
15
  attr_accessor :options
18
16
 
19
17
  def_delegators :command, :run
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../command'
4
+
5
+ module Dru
6
+ module Commands
7
+ class DockerCompose < Dru::Command
8
+ attr_reader :command
9
+
10
+ def initialize(options:, command:)
11
+ @options = options
12
+ @command = command
13
+ end
14
+
15
+ def execute(input: $stdin, output: $stdout)
16
+ run_docker_compose_command(*command, tty: true)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  module Dru
2
- VERSION = "0.5.2"
2
+ VERSION = "0.6.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.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Rimondi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-01-11 00:00:00.000000000 Z
12
+ date: 2019-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tty-color
@@ -361,10 +361,12 @@ files:
361
361
  - ext/dru/dru.h
362
362
  - ext/dru/extconf.rb
363
363
  - lib/dru.rb
364
+ - lib/dru/argv.rb
364
365
  - lib/dru/cli.rb
365
366
  - lib/dru/command.rb
366
367
  - lib/dru/commands/.gitkeep
367
368
  - lib/dru/commands/attach.rb
369
+ - lib/dru/commands/docker_compose.rb
368
370
  - lib/dru/commands/down.rb
369
371
  - lib/dru/commands/exec.rb
370
372
  - lib/dru/commands/runner.rb
@@ -373,6 +375,7 @@ files:
373
375
  - lib/dru/container_command.rb
374
376
  - lib/dru/templates/.gitkeep
375
377
  - lib/dru/templates/attach/.gitkeep
378
+ - lib/dru/templates/docker_compose/.gitkeep
376
379
  - lib/dru/templates/down/.gitkeep
377
380
  - lib/dru/templates/exec/.gitkeep
378
381
  - lib/dru/templates/runner/.gitkeep