Class: Byebug::HelpCommand
- Inherits:
-
Command
show all
- Includes:
- Columnize
- Defined in:
- lib/byebug/commands/help.rb
Overview
Ask for help from byebug’s prompt.
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
37
38
39
40
41
42
43
|
# File 'lib/byebug/commands/help.rb', line 37
def description
%(h[elp][ <command>[ <subcommand>]]
"help" alone prints this help.
"help <command>" prints help on <command>.
"help <command> <subcommand> prints help on <subcommand>.)
end
|
.names ⇒ Object
33
34
35
|
# File 'lib/byebug/commands/help.rb', line 33
def names
%w(help)
end
|
Instance Method Details
#execute ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/byebug/commands/help.rb', line 14
def execute
if @match[1]
args = @match[1].split
cmds = @state.commands.select { |cmd| cmd.names.include?(args[0]) }
if cmds.empty?
return errmsg("Undefined command: \"#{args[0]}\". Try \"help\"")
end
return puts(cmds.map { |cmd| cmd.help(args[1..-1]) }.join("\n"))
end
puts "byebug help v#{VERSION}" unless Setting[:testing]
puts "Type \"help <command-name>\" for help on a specific command\n"
puts 'Available commands:'
cmds = @state.commands.map { |cmd| cmd.names }.flatten.uniq.sort
puts columnize(cmds, Setting[:width])
end
|
#regexp ⇒ Object
10
11
12
|
# File 'lib/byebug/commands/help.rb', line 10
def regexp
/^\s* h(?:elp)? (?:\s+(.+))? \s*$/x
end
|