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
|
# File 'lib/dindi/command_parser.rb', line 10
def self.parse(args, options)
options.project_name = nil
options.with_bundle_install = false
opts = OptionParser.new do |opts|
opts.banner = "Usage: dindi [options]"
opts.separator " "
opts.separator "Specific options:"
opts.on("-n", "--name PROJECT_NAME",
"Specify your project name PROJECT_NAME that will be created") do |project_name|
options.project_name = project_name.downcase
end
opts.on("-b", "--[no-]bundle-install", "Run bundler install after project creation") do |b|
options.with_bundle_install = b
end
opts.on_tail("-h", "--help", "Show this message") do
puts opts
puts ""
raise
end
end
opts.parse!(args)
options.ruby_version = "latest"
options.project_absolute_dir = nil
if options.project_name
options.project_absolute_dir = File.join(FileUtils.pwd, options.project_name)
end
rescue Exception => e
if e.message.match(/invalid option/i) or e.message.match(/missing argument/i)
puts "ERROR: #{e.message}".red
puts ""
puts opts
puts ""
end
raise
end
|