Method: CMDB::Commands::Help#run

Defined in:
lib/cmdb/commands/help.rb

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cmdb/commands/help.rb', line 14

def run
  if @command.nil? || @command.empty?
    # Same as "--help"
    raise Trollop::HelpNeeded
  end

  # Find the command the user was talking about and print some help
  konst = CMDB::Commands.constants.detect { |konst| konst.to_s.downcase == @command }
  if konst
    klass = CMDB::Commands.const_get(konst)
    ARGV.clear ; ARGV.push('--help')
    klass.create(@cmdb)
  else
    CMDB.log.fatal "CMDB: Unknown command '#{@command}'; try 'cmdb --help' for a list of commands"
    exit 1
  end
end