Class: Byebug::HelpCommand

Inherits:
Command
  • Object
show all
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, #match

Methods included from StringFunctions

#camelize, #prettify

Methods included from FileFunctions

#get_line, #get_lines, #n_lines, #normalize

Methods included from ParseFunctions

#get_int, #parse_steps, #syntax_valid?

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject


28
29
30
31
32
33
34
35
36
# File 'lib/byebug/commands/help.rb', line 28

def description
  prettify <<-EOD
    h[elp][ <cmd>[ <subcmd>]]

    help                -- prints this help.
    help <cmd>          -- prints help on command <cmd>.
    help <cmd> <subcmd> -- prints help on <cmd>'s subcommand <subcmd>.
  EOD
end

.namesObject


24
25
26
# File 'lib/byebug/commands/help.rb', line 24

def names
  %w(help)
end

Instance Method Details

#executeObject


14
15
16
17
18
19
20
21
# File 'lib/byebug/commands/help.rb', line 14

def execute
  return puts(self.class.help) unless @match[1]

  cmd = Command.commands.select { |c| c.names.include?(@match[1]) }
  return errmsg(pr('help.errors.undefined', cmd: @match[1])) unless cmd.any?

  cmd.each { |c| puts c.help(@match[2]) }
end

#regexpObject


10
11
12
# File 'lib/byebug/commands/help.rb', line 10

def regexp
  /^\s* h(?:elp)? (?: \s+(\S+) (?:\s+(\S+))? )? \s*$/x
end