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
|
# File 'lib/docli/options_parse.rb', line 32
def self.file_parse argv
options = {}
opt_parser = OptionParser.new do |opt|
opt.banner = "Usage: docli create -f [FILE]"
opt.banner = " docli apply --file [FILE]"
opt.separator ""
opt.separator "Commands"
opt.separator " create: create new droplets on DigitalOcean"
opt.separator " list: list all droplets on DigitalOcean"
opt.separator ""
opt.separator "Options"
opt.on("-f ","--file ","File contain the resources define") do |file|
options[:file_config] = file
end
opt.on("-h","--help","show help message")
opt.separator ""
opt.separator "Show help command:"
opt.separator "docli droplets [COMMAND] --help"
end
opt_parser.parse!
if options[:file_config].nil?
puts "Please specify your config file".red
puts opt_parser
exit
end
context = YAML.load(File.open(options[:file_config]))
context.each do |key, value|
case value["resource_type"]
when "droplets"
Cmd::NewDroplets.create_new_droplets_from_file value
else
puts "Cannot get resource_type" + value['resource_type']
puts opt_parser
exit
end
end
end
|