lib/rcoli/help.rb in rcoli-0.5.0 vs lib/rcoli/help.rb in rcoli-0.5.1

- old
+ new

@@ -2,14 +2,23 @@ module RCoLi module Help - def help - puts template 'help' + def help(*args) + if args[0].empty? + puts template('help', nil) + else + command = self + args[0].each do |arg| + command = command.find_command(arg) + raise InvalidCommand, "'#{arg}' is not a valid #{@name} command" unless command + end + puts template('help_command', command) + end end - def template(name) + def template(name, command) ERB.new(File.read(File.join(File.dirname(__FILE__), 'templates', "#{name}.erb")), nil, '-').result binding end end \ No newline at end of file