Class: Byebug::ShowCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/byebug/commands/show.rb

Overview

Implements byebug “show” command.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, find, format_subcmd, format_subcmds, inherited, #initialize, load_commands, #match

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



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

def description
  <<-EOD.gsub(/^        /, '')

    show <setting> <value>

    Generic command for showing byebug settings. You can change them with
    the "set" command.

  EOD
end

.help(setting = nil) ⇒ Object



39
40
41
42
43
# File 'lib/byebug/commands/show.rb', line 39

def help(setting = nil)
  return "show #{setting.to_sym} <value>\n\n#{setting.help}" if setting

  description + Setting.format()
end

.namesObject



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

def names
  %w(show)
end

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/byebug/commands/show.rb', line 11

def execute
  key = @match[:setting]
  return print ShowCommand.help if key.nil?

  full_key = Setting.find(key)
  if full_key
    print Setting.settings[full_key.to_sym].to_s
  else
    print "Unknown setting :#{key}\n"
  end
end

#regexpObject



7
8
9
# File 'lib/byebug/commands/show.rb', line 7

def regexp
  /^\s* show (?:\s+(?<setting>\w+))? \s*$/x
end