Class: Byebug::HelpCommand
- Inherits:
-
Command
show all
- Includes:
- Columnize
- Defined in:
- lib/byebug/commands/help.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match
Class Method Details
.description ⇒ Object
40
41
42
43
44
|
# File 'lib/byebug/commands/help.rb', line 40
def description
%{h[elp]\t\tprint this help
h[elp] command\tprint help on command
h[elp] command subcommand\tprint help on subcommand}
end
|
.names ⇒ Object
36
37
38
|
# File 'lib/byebug/commands/help.rb', line 36
def names
%w(help)
end
|
Instance Method Details
#execute ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/byebug/commands/help.rb', line 11
def execute
if @match[1]
args = @match[1].split
cmds = @state.commands.select { |cmd| cmd.names.include?(args[0]) }
unless cmds.empty?
help = cmds.map{ |cmd| cmd.help(args) }.join("\n")
help = help.split("\n").map{|l| l.gsub(/^ +/, '')}
help.shift if help.first && help.first.empty?
help.pop if help.last && help.last.empty?
return print help.join("\n") + "\n"
else
return errmsg "Undefined command: \"#{args[0]}\". Try \"help\".\n" if
args[0]
end
end
print "byebug help v#{VERSION}\n" unless Setting[:testing]
print "Type \"help <command-name>\" for help on a specific command\n\n"
print "Available commands:\n"
cmds = @state.commands.map{ |cmd| cmd.names }.flatten.uniq.sort
print columnize(cmds, Setting[:width])
end
|
#regexp ⇒ Object
7
8
9
|
# File 'lib/byebug/commands/help.rb', line 7
def regexp
/^\s* h(?:elp)? (?:\s+(.+))? \s*$/x
end
|