Class: Debugger::HelpCommand
Overview
Constant Summary
Constants inherited
from Command
Command::DEF_OPTIONS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, inherited, #initialize, load_commands, #match, method_missing, options
Class Method Details
.help(cmd) ⇒ Object
39
40
41
42
43
44
|
# File 'lib/ruby-debug/commands/help.rb', line 39
def help(cmd)
%{
h[elp]\t\tprint this help
h[elp] command\tprint help on command
}
end
|
.help_command ⇒ Object
35
36
37
|
# File 'lib/ruby-debug/commands/help.rb', line 35
def help_command
'help'
end
|
Instance Method Details
#execute ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/ruby-debug/commands/help.rb', line 9
def execute
print "ruby-debug help v.#{Debugger::VERSION}\n"
cmds = @state.commands.select{ |cmd| [cmd.help_command].flatten.include?(@match[1]) }
unless cmds.empty?
help = cmds.map{ |cmd| cmd.help(@match[1]) }.join
print help.split("\n").reject{|l| l =~ /^\s*$/ }.map{|l| l.gsub(/^ +/, '')}.join("\n")
else
print "Available commands:\n"
cmds = @state.commands.map{ |cmd| cmd.help_command }
cmds = cmds.flatten.uniq.sort
buf = ""
cmds.each do |cmd|
if buf.length + cmd.length > 70
print "%s\n", buf
buf = ""
else
buf << cmd << ' '
end
end
print "%s\n", buf if buf.length > 0
end
print "\n"
end
|
#regexp ⇒ Object
5
6
7
|
# File 'lib/ruby-debug/commands/help.rb', line 5
def regexp
/^\s*h(?:elp)?(?:\s+(.+))?$/
end
|