Module: HammerCLIKatelloBridge

Defined in:
lib/hammer_cli_katello_bridge.rb,
lib/hammer_cli_katello_bridge/version.rb

Defined Under Namespace

Classes: KatelloCommand

Class Method Summary collapse

Class Method Details

.convert_commands(command_list, prefix) ⇒ Object



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

.load_commands(cli_definition) ⇒ Object



54
55
56
57
# File 'lib/hammer_cli_katello_bridge.rb', line 54

def self.load_commands(cli_definition)
  json = JSON.parse(cli_definition)
  commands = self.convert_commands(json, '')
end

.versionObject



2
3
4
# File 'lib/hammer_cli_katello_bridge/version.rb', line 2

def self.version
  @version ||= Gem::Version.new '0.0.7'
end