docker-cli 0.3.1 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.release_history.yml +2 -0
- data/.rubocop.yml +2 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +24 -27
- data/Rakefile +2 -1
- data/docker-cli.gemspec +5 -2
- data/exe/_gemdocker +225 -0
- data/exe/dc-update +24 -0
- data/exe/gemdocker +52 -0
- data/exe/gemdocker_test +40 -0
- data/lib/docker/cli/command.rb +37 -31
- data/lib/docker/cli/command_factory.rb +62 -27
- data/lib/docker/cli/command_result.rb +16 -0
- data/lib/docker/cli/docker_composer.rb +113 -0
- data/lib/docker/cli/docker_container.rb +216 -0
- data/lib/docker/cli/docker_image.rb +205 -0
- data/lib/docker/cli/docker_run_log.rb +169 -0
- data/lib/docker/cli/dockerfile.rb +62 -0
- data/lib/docker/cli/dockerfile_template/dup_gem_bundler_env.rb +73 -0
- data/lib/docker/cli/dockerfile_template/match_user.rb +38 -0
- data/lib/docker/cli/dockerfile_template.rb +69 -0
- data/lib/docker/cli/gem/bundler_helper.rb +25 -0
- data/lib/docker/cli/image_helper.rb +43 -0
- data/lib/docker/cli/operations/args_parser.rb +53 -0
- data/lib/docker/cli/operations/run.rb +203 -0
- data/lib/docker/cli/operations/run_del.rb +67 -0
- data/lib/docker/cli/operations/run_keep.rb +118 -0
- data/lib/docker/cli/user_info.rb +39 -0
- data/lib/docker/cli/version.rb +1 -1
- data/lib/docker/cli.rb +64 -0
- data/scripts/create_user.sh.erb +10 -0
- metadata +51 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7de8845afde832587cc19c8266177a0a909805a28ac6f26fd3663a9b328d6f92
|
4
|
+
data.tar.gz: 06b86993c73cfafb99ddc8dd9c00cc73d8bad24e636882362e3e3231652a8f41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a49c960fc1462a972a3ebe1f3f502a430ecd389f2b7f00c9af9781959e22c0df7dadce23b3dbd069caa78c91c62d483eba6ed28000f1b279c81f0bd659cdaada
|
7
|
+
data.tar.gz: c6816d24a2efd38599aaaacc96d2aa7158fbf4315108aa1996c9b12ca875c7bec8c911eea7f54ba8e272a4249048444a462c87920d961631d61aae07d18d147d
|
data/.release_history.yml
CHANGED
data/.rubocop.yml
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,53 +1,50 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
docker-cli (0.
|
4
|
+
docker-cli (0.5.1)
|
5
|
+
colorize
|
5
6
|
ptools
|
6
7
|
teLogger
|
7
|
-
toolrack
|
8
|
+
toolrack (= 0.24.1)
|
8
9
|
tty-command
|
9
10
|
tty-prompt
|
10
11
|
|
11
12
|
GEM
|
12
13
|
remote: https://rubygems.org/
|
13
14
|
specs:
|
14
|
-
|
15
|
-
git_cli
|
16
|
-
git_cli_prompt (~> 0.3.3)
|
17
|
-
gvcs
|
18
|
-
teLogger
|
19
|
-
toolrack
|
20
|
-
tty-prompt
|
15
|
+
colorize (1.1.0)
|
21
16
|
diff-lcs (1.5.0)
|
22
|
-
git_cli (0.
|
23
|
-
gvcs
|
17
|
+
git_cli (0.13.9)
|
24
18
|
ptools (~> 1.4.0)
|
25
|
-
teLogger
|
26
|
-
toolrack
|
27
|
-
git_cli_prompt (0.3.4)
|
28
|
-
teLogger
|
29
|
-
toolrack
|
30
|
-
tty-prompt
|
31
|
-
gvcs (0.1.1)
|
19
|
+
teLogger (> 0.2)
|
20
|
+
toolrack (> 0.23)
|
32
21
|
pastel (0.8.0)
|
33
22
|
tty-color (~> 0.5)
|
34
23
|
ptools (1.4.3)
|
35
|
-
rake (13.0
|
24
|
+
rake (13.1.0)
|
25
|
+
release-gem (0.3.3)
|
26
|
+
colorize (~> 1.1)
|
27
|
+
git_cli (~> 0.13)
|
28
|
+
pastel (~> 0.8)
|
29
|
+
teLogger (~> 0.2)
|
30
|
+
toolrack (~> 0.23)
|
31
|
+
tty-command (~> 0.10)
|
32
|
+
tty-prompt (~> 0.23)
|
36
33
|
rspec (3.12.0)
|
37
34
|
rspec-core (~> 3.12.0)
|
38
35
|
rspec-expectations (~> 3.12.0)
|
39
36
|
rspec-mocks (~> 3.12.0)
|
40
|
-
rspec-core (3.12.
|
37
|
+
rspec-core (3.12.2)
|
41
38
|
rspec-support (~> 3.12.0)
|
42
|
-
rspec-expectations (3.12.
|
39
|
+
rspec-expectations (3.12.3)
|
43
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
44
41
|
rspec-support (~> 3.12.0)
|
45
|
-
rspec-mocks (3.12.
|
42
|
+
rspec-mocks (3.12.6)
|
46
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
47
44
|
rspec-support (~> 3.12.0)
|
48
|
-
rspec-support (3.12.
|
45
|
+
rspec-support (3.12.1)
|
49
46
|
teLogger (0.2.2)
|
50
|
-
toolrack (0.
|
47
|
+
toolrack (0.24.1)
|
51
48
|
tty-color (0.6.0)
|
52
49
|
tty-command (0.10.1)
|
53
50
|
pastel (~> 0.8)
|
@@ -59,7 +56,7 @@ GEM
|
|
59
56
|
tty-cursor (~> 0.7)
|
60
57
|
tty-screen (~> 0.8)
|
61
58
|
wisper (~> 2.0)
|
62
|
-
tty-screen (0.8.
|
59
|
+
tty-screen (0.8.2)
|
63
60
|
wisper (2.0.1)
|
64
61
|
|
65
62
|
PLATFORMS
|
@@ -67,10 +64,10 @@ PLATFORMS
|
|
67
64
|
x86_64-linux
|
68
65
|
|
69
66
|
DEPENDENCIES
|
70
|
-
devops_assist
|
71
67
|
docker-cli!
|
72
68
|
rake (~> 13.0)
|
69
|
+
release-gem
|
73
70
|
rspec (~> 3.0)
|
74
71
|
|
75
72
|
BUNDLED WITH
|
76
|
-
2.
|
73
|
+
2.5.1
|
data/Rakefile
CHANGED
data/docker-cli.gemspec
CHANGED
@@ -30,19 +30,22 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
|
-
spec.add_dependency 'toolrack'
|
33
|
+
#spec.add_dependency 'toolrack'
|
34
34
|
spec.add_dependency 'teLogger'
|
35
35
|
|
36
36
|
spec.add_dependency 'ptools'
|
37
37
|
|
38
38
|
spec.add_dependency 'tty-command'
|
39
|
+
spec.add_dependency 'colorize'
|
39
40
|
spec.add_dependency 'tty-prompt'
|
40
41
|
|
41
|
-
spec.add_development_dependency 'devops_assist'
|
42
|
+
#spec.add_development_dependency 'devops_assist'
|
42
43
|
|
43
44
|
# Uncomment to register a new dependency of your gem
|
44
45
|
# spec.add_dependency "example-gem", "~> 1.0"
|
45
46
|
|
46
47
|
# For more information and examples about making a new gem, checkout our
|
47
48
|
# guide at: https://bundler.io/guides/creating_gem.html
|
49
|
+
spec.add_development_dependency 'release-gem'
|
50
|
+
spec.add_dependency "toolrack", "0.24.1"
|
48
51
|
end
|
data/exe/_gemdocker
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/docker/cli'
|
4
|
+
|
5
|
+
include TR::CondUtils
|
6
|
+
|
7
|
+
pmt = TTY::Prompt.new
|
8
|
+
|
9
|
+
root = Dir.getwd
|
10
|
+
dockerfile = File.join(root, "Dockerfile")
|
11
|
+
|
12
|
+
# Should spin off jruby:9.4.2.0-jdk and land on console
|
13
|
+
# > gemdocker jruby:9.4.2.0-jdk
|
14
|
+
#
|
15
|
+
|
16
|
+
|
17
|
+
again = true
|
18
|
+
while again
|
19
|
+
if not File.exist?(dockerfile)
|
20
|
+
dockerfile = pmt.ask(" #{dockerfile} does not exist. Please provide new location of Dockerfile: ", required: true)
|
21
|
+
else
|
22
|
+
again = false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
cf = Docker::Cli::CommandFactory.new
|
28
|
+
begin
|
29
|
+
|
30
|
+
existing = false
|
31
|
+
again = true
|
32
|
+
while again
|
33
|
+
dname = pmt.ask("Please provide name of image at local : ", required: true)
|
34
|
+
ficr = cf.find_image(dname)
|
35
|
+
if ficr.success?
|
36
|
+
if ficr.is_out_stream_empty?
|
37
|
+
again = false
|
38
|
+
else
|
39
|
+
reuse = pmt.yes?(" Given local image name '#{dname}' already taken. Use back the same image? 'No' to retry with new name : ")
|
40
|
+
if not reuse
|
41
|
+
again
|
42
|
+
else
|
43
|
+
existing = true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
else
|
47
|
+
raise CommandFailed, "Failed to find Docker image. Error was : #{ficr.err_stream}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
if not existing
|
52
|
+
cr = cf.build_image(dname, dockerfile: dockerfile).run
|
53
|
+
STDOUT.puts cr.out_stream if not cr.is_out_stream_empty?
|
54
|
+
raise CommandFailed, "Failed to build image with name '#{dname}' using dockerfile '#{dockerfile}'. Error was : #{cr.err_stream}"
|
55
|
+
end
|
56
|
+
|
57
|
+
reuse = false
|
58
|
+
again = true
|
59
|
+
while again
|
60
|
+
contName = pmt.ask(" Please provide a name for container : ", required: true)
|
61
|
+
ir = cf.find_from_all_container(contName)
|
62
|
+
if ir.successful?
|
63
|
+
if ir.is_out_stream_empty?
|
64
|
+
# not found
|
65
|
+
again = false
|
66
|
+
else
|
67
|
+
reuse = pmt.yes? "Given container name '#{contName}' already exist. Do you want to reuse the existing container? "
|
68
|
+
if reuse
|
69
|
+
|
70
|
+
again = false
|
71
|
+
else
|
72
|
+
|
73
|
+
again = false
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
if reuse
|
80
|
+
rcf = cf.find_running_container(contName)
|
81
|
+
if rcf.successful?
|
82
|
+
if rcf.is_out_stream_empty?
|
83
|
+
# not found
|
84
|
+
scrv = cf.start_container(contName)
|
85
|
+
if not scrv.successful?
|
86
|
+
raise CommandFailed, "Failed to start container '#{contName}'. Error was : #{scrv.err_stream}"
|
87
|
+
end
|
88
|
+
|
89
|
+
ucmd = pmt.ask(" Command to be run inside the container. Empty to attach to existing session : ", value: "/bin/bash")
|
90
|
+
if is_empty?(ucmd)
|
91
|
+
cf.attach_container(contName).run
|
92
|
+
else
|
93
|
+
cf.run_command_in_running_container(contName, ucmd, tty: true, interactive: true).run
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
else
|
100
|
+
|
101
|
+
@workspace_root = "/opt"
|
102
|
+
@shared_dirs = {}
|
103
|
+
|
104
|
+
#@workspace_root = pmt.ask(" Where is the root of the workspace to be? : ", required: true, default: "/opt")
|
105
|
+
|
106
|
+
mount = []
|
107
|
+
res = find_local_dev_gems
|
108
|
+
if not res.empty?
|
109
|
+
|
110
|
+
STDOUT.puts "Found #{res.length} development gems in the configuration"
|
111
|
+
|
112
|
+
res.each do |name, path|
|
113
|
+
proot = pmt.ask("Found development gem path '#{path}'. Where would you want to map the gem inside the Docker? ", required: true, default: @workspace_root)
|
114
|
+
dkPath = File.join(proot, path)
|
115
|
+
mount << { path => dkPath }
|
116
|
+
@shared_dirs[name] = tsrc
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
mapProjectDir = pmt.ask(" Where do you want to map the current directory? Empty to skip mapping : ", default: @workspace_root)
|
122
|
+
if not_empty?(mapProjectDir)
|
123
|
+
mount << { Dir.getwd => mapProjectDir }
|
124
|
+
end
|
125
|
+
|
126
|
+
reqVolMap = block.call(:volume_mapping_required?)
|
127
|
+
if reqVolMap
|
128
|
+
|
129
|
+
loop do
|
130
|
+
|
131
|
+
block.call(:already_mapped, mount)
|
132
|
+
|
133
|
+
src = block.call(:source_prompt, { control: [ "Empty to end" ] })
|
134
|
+
if is_empty?(src)
|
135
|
+
block.call(:volume_mapping_skipped)
|
136
|
+
break
|
137
|
+
end
|
138
|
+
|
139
|
+
dest = block.call(:destination_prompt, src)
|
140
|
+
mount << { src => dest }
|
141
|
+
|
142
|
+
add_to_bundle = block.call(:add_to_bundle?, dest)
|
143
|
+
if add_to_bundle
|
144
|
+
@shared_dirs[File.basename(dest)] = dest
|
145
|
+
end
|
146
|
+
|
147
|
+
#repeat = block.call(:add_more_volume_mapping?)
|
148
|
+
#break if not repeat
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
@workspace_root = "/opt"
|
155
|
+
@shared_dirs = {}
|
156
|
+
|
157
|
+
block.call(:prompt_mount_points_starting)
|
158
|
+
|
159
|
+
mount = []
|
160
|
+
res = find_local_dev_gems
|
161
|
+
#puts "Found #{res.length} local gems #{res}"
|
162
|
+
if not res.empty?
|
163
|
+
|
164
|
+
transferMapping = block.call(:transfer_dev_gem_mapping?, res)
|
165
|
+
if transferMapping
|
166
|
+
res.each do |name, path|
|
167
|
+
loop do
|
168
|
+
if not File.exist?(path)
|
169
|
+
path = block.call(:dev_gem_path_not_found, path)
|
170
|
+
else
|
171
|
+
break
|
172
|
+
end
|
173
|
+
end
|
174
|
+
tsrc = block.call(:workspace_root_inside_docker, @workspace_root, name, path)
|
175
|
+
mount << { path => tsrc }
|
176
|
+
@shared_dirs[name] = tsrc
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
mapProjectDir = block.call(:map_project_dir, @workspace_root)
|
183
|
+
if not_empty?(mapProjectDir)
|
184
|
+
mount << { Dir.getwd => mapProjectDir }
|
185
|
+
end
|
186
|
+
|
187
|
+
reqVolMap = block.call(:volume_mapping_required?)
|
188
|
+
if reqVolMap
|
189
|
+
|
190
|
+
loop do
|
191
|
+
|
192
|
+
block.call(:already_mapped, mount)
|
193
|
+
|
194
|
+
src = block.call(:source_prompt, { control: [ "Empty to end" ] })
|
195
|
+
if is_empty?(src)
|
196
|
+
block.call(:volume_mapping_skipped)
|
197
|
+
break
|
198
|
+
end
|
199
|
+
|
200
|
+
dest = block.call(:destination_prompt, src)
|
201
|
+
mount << { src => dest }
|
202
|
+
|
203
|
+
add_to_bundle = block.call(:add_to_bundle?, dest)
|
204
|
+
if add_to_bundle
|
205
|
+
@shared_dirs[File.basename(dest)] = dest
|
206
|
+
end
|
207
|
+
|
208
|
+
#repeat = block.call(:add_more_volume_mapping?)
|
209
|
+
#break if not repeat
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
nc = cf.create_container_from_image(dname, { interactive: true, tty: true, container_name: contName })
|
218
|
+
|
219
|
+
end
|
220
|
+
|
221
|
+
|
222
|
+
rescue Exception => ex
|
223
|
+
STDERR.puts "\n Exception raised : #{ex.message} \n"
|
224
|
+
end
|
225
|
+
|
data/exe/dc-update
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'tty/prompt'
|
4
|
+
require 'colorize'
|
5
|
+
|
6
|
+
require_relative '../lib/docker/cli'
|
7
|
+
|
8
|
+
pmt = TTY::Prompt.new
|
9
|
+
# dc-update docker-compose.yml.tmp docker-compose.yml
|
10
|
+
begin
|
11
|
+
STDOUT.puts "\n Docker Cli version #{Docker::Cli::VERSION}".green
|
12
|
+
Docker::Cli::DockerComposer.new.parse_argv(ARGV) do |key, *val|
|
13
|
+
case key
|
14
|
+
when :prompt_docker_mount_root
|
15
|
+
pmt.ask(" Please provide the root to mount inside docker : ", required: true, default: '/opt')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
rescue TTY::Reader::InputInterrupt
|
19
|
+
rescue ArgsParser::ArgParserException => ex
|
20
|
+
STDERR.puts ex.message.red
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
data/exe/gemdocker
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
require 'colorize'
|
5
|
+
require_relative '../lib/docker/cli'
|
6
|
+
|
7
|
+
require_relative '../lib/docker/cli/operations/args_parser'
|
8
|
+
|
9
|
+
include TR::CondUtils
|
10
|
+
include Docker::Cli
|
11
|
+
|
12
|
+
begin
|
13
|
+
STDOUT.puts "\n Docker Cli version #{Docker::Cli::VERSION}".green
|
14
|
+
ArgsParser.new.parse_argv(ARGV)
|
15
|
+
rescue TTY::Reader::InputInterrupt
|
16
|
+
rescue ArgsParser::ArgsParserException => ex
|
17
|
+
STDERR.puts ex.message.red
|
18
|
+
#STDERR.puts ex.backtrace.join("\n")
|
19
|
+
end
|
20
|
+
|
21
|
+
#if ARGV.length > 0
|
22
|
+
# #
|
23
|
+
# # Should spin off jruby:9.4.2.0-jdk and land on console
|
24
|
+
# # > gemdocker jruby:9.4.2.0-jdk
|
25
|
+
# #
|
26
|
+
# dimage = ARGV.first
|
27
|
+
# cmd = ARGV[1] || "/bin/bash"
|
28
|
+
#
|
29
|
+
# contName = SecureRandom.hex(8)
|
30
|
+
#
|
31
|
+
# mountLocal = Dir.getwd
|
32
|
+
# mountDocker = "/opt/#{File.basename(Dir.getwd)}"
|
33
|
+
# # user & group created but cannot switch to the user
|
34
|
+
# # User creation and login cannot be on the same session
|
35
|
+
# #Docker::Cli::DockerContainer.prep_container(dimage, mount_local: mountLocal, mount_docker: mountDocker, container_name: contName, mount: { mountLocal => mountDocker })
|
36
|
+
#
|
37
|
+
# #cont = Docker::Cli::DockerContainer.new(contName)
|
38
|
+
# #cont.start if not cont.is_running?
|
39
|
+
# #cont.run_command(cmd, interactive: true, tty: true)
|
40
|
+
# #Docker::Cli::DockerContainer.create_container(dimage, interactive: true, tty: true, command: cmd, container_name: contName, mount: { mountLocal => mountDocker }, match_user: true)
|
41
|
+
#
|
42
|
+
# # This approach has user match with local user but no name on the docker
|
43
|
+
# # workable not nice only
|
44
|
+
# Docker::Cli::DockerContainer.create_container(dimage, interactive: true, tty: true, command: cmd, mount: { mountLocal => mountDocker }, match_user: true)
|
45
|
+
#
|
46
|
+
#else
|
47
|
+
# # interactive
|
48
|
+
# puts "Interactive coming soon..."
|
49
|
+
#end
|
50
|
+
|
51
|
+
|
52
|
+
|
data/exe/gemdocker_test
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
require_relative '../lib/docker/cli'
|
5
|
+
|
6
|
+
include TR::CondUtils
|
7
|
+
|
8
|
+
|
9
|
+
if ARGV.length > 0
|
10
|
+
#
|
11
|
+
# Should spin off jruby:9.4.2.0-jdk and land on console
|
12
|
+
# > gemdocker jruby:9.4.2.0-jdk
|
13
|
+
#
|
14
|
+
dimage = ARGV.first
|
15
|
+
cmd = ARGV[1] || "/bin/bash"
|
16
|
+
|
17
|
+
contName = SecureRandom.hex(8)
|
18
|
+
|
19
|
+
mountLocal = Dir.getwd
|
20
|
+
mountDocker = "/opt/#{File.basename(Dir.getwd)}"
|
21
|
+
# user & group created but cannot switch to the user
|
22
|
+
# User creation and login cannot be on the same session
|
23
|
+
#Docker::Cli::DockerContainer.prep_container(dimage, mount_local: mountLocal, mount_docker: mountDocker, container_name: contName, mount: { mountLocal => mountDocker })
|
24
|
+
|
25
|
+
#cont = Docker::Cli::DockerContainer.new(contName)
|
26
|
+
#cont.start if not cont.is_running?
|
27
|
+
#cont.run_command(cmd, interactive: true, tty: true)
|
28
|
+
#Docker::Cli::DockerContainer.create_container(dimage, interactive: true, tty: true, command: cmd, container_name: contName, mount: { mountLocal => mountDocker }, match_user: true)
|
29
|
+
|
30
|
+
# This approach has user match with local user but no name on the docker
|
31
|
+
# workable not nice only
|
32
|
+
Docker::Cli::DockerContainer.create_container(dimage, interactive: true, tty: true, command: cmd, mount: { mountLocal => mountDocker }, match_user: true)
|
33
|
+
|
34
|
+
else
|
35
|
+
# interactive
|
36
|
+
puts "Interactive coming soon..."
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
|
data/lib/docker/cli/command.rb
CHANGED
@@ -11,6 +11,9 @@ module Docker
|
|
11
11
|
module Cli
|
12
12
|
class Command
|
13
13
|
include TR::CondUtils
|
14
|
+
include TR::TerminalUtils
|
15
|
+
|
16
|
+
class CommandError < StandardError; end
|
14
17
|
|
15
18
|
attr_accessor :command_buffer
|
16
19
|
def initialize(cmd, required_interaction = false)
|
@@ -38,37 +41,40 @@ module Docker
|
|
38
41
|
end
|
39
42
|
|
40
43
|
if terminal != :quit
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
44
|
+
|
45
|
+
tu_new_terminal(terminal, @command_buffer)
|
46
|
+
|
47
|
+
#case terminal
|
48
|
+
#when "terminator"
|
49
|
+
# `#{terminal} -x "#{@command_buffer.join(" ")}"`
|
50
|
+
#when "gnome-terminal"
|
51
|
+
# `#{terminal} -- bash -c "#{@command_buffer.join(" ")}; exec bash"`
|
52
|
+
#when "iTerm2"
|
53
|
+
# `osascript -e \
|
54
|
+
# 'tell application "iTerm"
|
55
|
+
# activate
|
56
|
+
|
57
|
+
# create window with default profile
|
58
|
+
# delay 0.5
|
59
|
+
|
60
|
+
# set currentWindow to current window
|
61
|
+
|
62
|
+
# tell current session of currentWindow
|
63
|
+
# write text "#{@command_buffer.join(" ")}"
|
64
|
+
# end tell
|
65
|
+
|
66
|
+
# end tell'
|
67
|
+
# `
|
68
|
+
#when "Terminal"
|
69
|
+
# `osascript -e \
|
70
|
+
# 'tell application "Terminal"
|
71
|
+
# activate
|
72
|
+
# do script "#{@command_buffer.join(" ")}"
|
73
|
+
# end tell'
|
74
|
+
# `
|
75
|
+
#else
|
76
|
+
# raise Error, "Unfinished supporting terminal : #{terminal}"
|
77
|
+
#end
|
72
78
|
|
73
79
|
pmt.puts "\n Prompt running inside the Docker shall be opened in a new window\n\n"
|
74
80
|
end
|