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
|
# File 'lib/addax.rb', line 50
def parse
if ARGV.size == 2 && %w(l list).include?(ARGV[0]) && %w(operating_systems oses platforms drivers strategies).include?(ARGV[1])
Addax::Commands.list(ARGV[1])
elsif ARGV.size == 2 && %w(operating_system os driver platform).include?(ARGV[0])
Addax::Commands.show(ARGV[0], ARGV[1])
elsif ARGV.size == 3 && %w(g generate).include?(ARGV[0])
Addax::Commands.generate(ARGV[1], ARGV[2])
elsif ARGV.size > 2 && %w(c create).include?(ARGV[0]) && %w(operating_system os platform driver).include?(ARGV[1])
Addax::Commands.send("create_#{ARGV[1]}".to_sym, ARGV[2..-1])
elsif ARGV.size == 4 && %w(f fetch).include?(ARGV[0]) && %w(driver platform).include?(ARGV[1])
Addax::Commands.send("fetch_#{ARGV[1]}".to_sym, ARGV[2], ARGV[3])
elsif ARGV.size > 3 && %w(u update).include?(ARGV[0]) && %w(operating_system os platform driver).include?(ARGV[1])
Addax::Commands.update(ARGV[1], ARGV[2], ARGV[3..-1])
elsif ARGV.size >= 3 && %w(d destroy).include?(ARGV[0])
if ARGV[1] == '-f'
Addax::Commands.destroy(ARGV[2], ARGV[3])
else
begin
puts "Please confirm that you wish to destroy this resource (Y/n)"
line = Readline.readline()
end while !%w(Y n).include?(line)
if line == 'Y'
Addax::Commands.destroy(ARGV[1], ARGV[2])
end
end
else
raise ArgumentError
end
end
|