59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/hammer_cli_katello_bridge.rb', line 59
def self.convert_commands(command_list, prefix)
commands = {}
command_buffer = []
command_list.each do |command|
command_name = command['name']
commands[command_name] = Class.new KatelloCommand
command_prefix = prefix.empty? ? command_name : "#{prefix} #{command_name}"
commands[command_name].command_prefix = command_prefix
command['options'].each do |opt|
dest = (opt['dest'] || 'arg').upcase
commands[command_name].option opt['names'], dest, opt['description'], :required => opt['required']
end
self.convert_commands(command['subcommands'], command_prefix).each do |c|
commands[command_name].subcommand c[:name], c[:desc], c[:cls]
end
command_buffer << { :name=>command_name, :desc=>command['description'], :cls=>commands[command_name] }
end
command_buffer
end
|