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
|
# File 'lib/options.rb', line 12
def parse_options
options = { verbose: false }
OptionParser.new do |parser|
@parser = parser
parser.on("-c", "--config", "Specify the yml config file to use") do |c|
options[:config] = c
end
parser.on("-d", "--delete", "Delete files copied over from init command") do |d|
options[:delete] = true
end
parser.on("-f", "--force", "Force initialization even if target files already exist") do |f|
options[:force] = true
end
parser.on("-t", "--template", "Specify the path the to the Vagrantfile template") do |t|
options[:template] = t
end
parser.on("-v", "--version", "Shows the version number") do |v|
options[:version] = true
end
parser.on("-h", "--help", "Show this help message") do |h|
options[:help] = true
end
parser.on("-i", "--init", "Initialize provision-vagrant with files it needs to operate") do |i|
options[:init] = true
end
end.parse!
if options[:version]
help(ProvisionVagrant.version)
end
if options[:help]
help
end
if options[:delete]
Generator.new.delete
exit(true)
end
if options[:config] && !File.exist?(options[:config])
help "Error: Invalid config file specified (not found): #{CONFIG}"
end
if options[:temlpate] && !File.exist(options[:template])
help "Error: Invalid template file specified (not found): #{TEMPLATE}"
end
if options[:init]
initiliazer = PvInitializer.new(options)
initiliazer.init
exit(true)
end
options
end
|