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
|
# File 'lib/commands/run.rb', line 11
def parse_options(o)
raise ArgumentError.new('image is required') if !o[:image]
s = ''
s += "#{o[:options]} " if o[:options]
if o[:detach]
s += "-d "
else
s += "--rm "
end
if o[:volumes]
raise ArgumentError.new('volumes must be an array') if !o[:volumes].is_a?(Array)
o[:volumes].each do |volume|
s += "-v #{volume} "
end
end
if o[:ports]
raise ArgumentError.new('ports must be an array') if !o[:ports].is_a?(Array)
o[:ports].each do |port|
s += "-p #{port} "
end
end
if o[:env]
raise ArgumentError.new('env must be an array') if !o[:env].is_a?(Array)
o[:env].each do |v|
s += "-e #{v} "
end
end
s += "--name=#{o[:name]}" if o[:name]
s += "#{o[:image]} "
s += "#{o[:command]} " if o[:command]
s
end
|