9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/vagrant-docker-nsenter/command/nsenter.rb', line 9
def execute
options = {}
options[:interactive] = true
options[:prefix] = true
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant docker-nsenter [command...]"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("--[no-]interactive", "Run the command interactively") do |i|
options[:interactive] = i
end
o.on("--[no-]prefix", "Prefix the output with the machine name") do |p|
options[:prefix] = p
end
end
command = nil
split_index = @argv.index("--")
if split_index
command = @argv.drop(split_index + 1)
@argv = @argv.take(split_index)
end
argv = parse_options(opts)
return if !argv
if !split_index
command = ["/bin/bash"]
end
target_opts = { provider: :docker }
target_opts[:single_target] = options[:pty]
with_target_vms(argv, target_opts) do |machine|
execute_single(machine, options, command)
end
0
end
|