dru 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/exe/dru +1 -1
- data/lib/dru.rb +6 -1
- data/lib/dru/argv.rb +27 -0
- data/lib/dru/cli.rb +33 -5
- data/lib/dru/command.rb +0 -2
- data/lib/dru/commands/docker_compose.rb +20 -0
- data/lib/dru/templates/docker_compose/.gitkeep +1 -0
- data/lib/dru/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f75222fea85c8eefdd69ea93f802d91ebee51005ba4c1101ced62c4982743b2b
|
4
|
+
data.tar.gz: 39838ee39b7a874223b4b7986ff4574fc22067e1944a50c2d3169843a36d781c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09f30684009c75b7d32b458e14de955d950bb9113653c843d2b22a895ae4ecde977cb6a5551a0a568d307f6eea3e7526a1049c311f199c72609b4beaa0dfd366'
|
7
|
+
data.tar.gz: b9b79033ee1d5e9624e59fd4fb056c7a05f0144d1f96681e9d5624203cf52ca1bb6e91de969d98465d01af7d01c6909bb56eb7aa2fda74df940747be00b96957
|
data/Gemfile.lock
CHANGED
data/exe/dru
CHANGED
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 }
|
data/lib/dru/argv.rb
ADDED
@@ -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
|
data/lib/dru/cli.rb
CHANGED
@@ -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
|
-
|
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']
|
data/lib/dru/command.rb
CHANGED
@@ -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
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
data/lib/dru/version.rb
CHANGED
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.
|
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-
|
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
|