8
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/blender/cli/start.rb', line 8
def parse_options(args)
options = {}
args, = args.inject([[]]) do |result, element|
if element == '--'
result << []
else
result.last << element
end
result
end
opts = OptionParser.new do |opts|
opts.banner = "Usage: blender start [OPTIONS] [-- [ec2run options]]"
opts.separator "Options:"
opts.on("-a", "--ami AMI",
"use specified AMI instead of the default one.",
"If you don't specify your own AMI blender will choose a defaule one:",
"* #{AMI_32} for 32 bits",
"* #{AMI_64} for 64 bits",
"You can change the defaults by writing your own AMIs",
"into ~/.blender/ami and ~/.blender/ami64 files"
) do |val|
options[:ami] = val
end
opts.separator ""
opts.on("-k", "--key KEY",
"use KEY when starting instance. KEY should already be generated.",
"If you don't specify a KEY blender will try to use the key from your EC2 account",
"Note: There must be only ONE key on the account for it to work."
) do |val|
options[:key] = val
end
opts.separator ""
opts.on("--64", "use 64 bit default AMI. This does nothing if you specify your own AMI") do
options[64] = true
end
opts.on("-n", "--dry-run", "Don't do anything, just print the command line to be executed") do |val|
@dry = options[:dry] = true
end
opts.separator "\nCommon options:"
opts.on("-h", "--help", "Show this message") do
raise(opts.to_s)
end
opts.on_tail <<-EXAMPLE
Example:
# start a 64bit instance with default options
blender start -64
# start with a custom ami
blender start --ami ami-2d4aa444
# start with passing arguments to ec2run: use security group default+test
blender start -- -g default -g test
EXAMPLE
end
opts.parse!(args)
raise("unexpected: #{args*" "}\n#{opts}") unless args.empty?
return options,
end
|