Class: CMDB::Commands::Help
- Inherits:
-
Object
- Object
- CMDB::Commands::Help
- Defined in:
- lib/cmdb/commands/help.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(interface, command) ⇒ Help
constructor
A new instance of Help.
- #run ⇒ Object
Constructor Details
#initialize(interface, command) ⇒ Help
Returns a new instance of Help.
9 10 11 12 |
# File 'lib/cmdb/commands/help.rb', line 9 def initialize(interface, command) @cmdb = interface @command = command end |
Class Method Details
.create(interface) ⇒ Object
5 6 7 |
# File 'lib/cmdb/commands/help.rb', line 5 def self.create(interface) new(interface, ARGV.first) end |
Instance Method Details
#run ⇒ Object
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 |