Class: Byebug::ShowCommand

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

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



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

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



37
38
39
40
41
# File 'lib/byebug/commands/show.rb', line 37

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

  description + Setting.format()
end

.namesObject



22
23
24
# File 'lib/byebug/commands/show.rb', line 22

def names
  %w(show)
end

Instance Method Details

#executeObject



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

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



5
6
7
# File 'lib/byebug/commands/show.rb', line 5

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