Class Debugger::HelpCommand
In: cli/ruby-debug/commands/help.rb
Parent: Command

Implements debugger "help" command.

Methods

execute   help   help_command   regexp  

Public Class methods

Returns a String given the help description of this command

[Source]

    # File cli/ruby-debug/commands/help.rb, line 53
53:       def help(cmd)
54:         %{
55:           h[elp]\t\tprint this help
56:           h[elp] command\tprint help on command
57:         }
58:       end

The command name listed via ‘help

[Source]

    # File cli/ruby-debug/commands/help.rb, line 48
48:       def help_command
49:         'help'
50:       end

Public Instance methods

The code that implements this command.

[Source]

    # File cli/ruby-debug/commands/help.rb, line 14
14:     def execute
15:       if @match[1]
16:         args = @match[1].split
17:         cmds = @state.commands.select do |cmd| 
18:           [cmd.help_command].flatten.include?(args[0])
19:         end
20:       else
21:         args = @match[1]
22:         cmds = []
23:       end
24:       unless cmds.empty?
25:         help = cmds.map{ |cmd| cmd.help(args) }.join
26:         help = help.split("\n").map{|l| l.gsub(/^ +/, '')}
27:         help.shift if help.first && help.first.empty?
28:         help.pop if help.last && help.last.empty?
29:         print help.join("\n")
30:       else
31:         if args and args[0]
32:           errmsg "Undefined command: \"#{args[0]}\".  Try \"help\"."
33:         else
34:           print "ruby-debug help v#{Debugger::VERSION}\n" unless
35:             self.class.settings[:debuggertesting]
36:           print "Type 'help <command-name>' for help on a specific command\n\n"
37:           print "Available commands:\n"
38:           cmds = @state.commands.map{ |cmd| cmd.help_command }
39:           cmds = cmds.flatten.uniq.sort
40:           print columnize(cmds, self.class.settings[:width])
41:         end
42:       end
43:       print "\n"
44:     end

An input line is matched against this regular expression. If we have a match, run this command.

[Source]

    # File cli/ruby-debug/commands/help.rb, line 9
 9:     def regexp
10:       /^\s* h(?:elp)? (?:\s+(.+))? $/x
11:     end

[Validate]