Class: Byebug::EnableDisableCommand

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

Overview

Enabling or disabling custom display expressions or breakpoints.

Constant Summary collapse

Subcommands =
[
  ['breakpoints', 2, 'Enable/disable breakpoints. Give breakpoint '      \
                     'numbers (separated by spaces) as arguments or no ' \
                     'argument at all if you want to enable/disable '    \
                     'every breakpoint'],
  ['display', 2, 'Enable/disable some expressions to be displayed when ' \
                 ' when program stops. Arguments are the code numbers '  \
                 'of the expressions to resume/stop displaying. Do '     \
                 '"info display" to see the current list of code '       \
                 'numbers']
].map do |name, min, help|
  Subcmd.new(name, min, help)
end

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/byebug/commands/enable_disable.rb', line 110

def description
  %{(en|dis)[able][[ (breakpoints|display)][ n1[ n2[ ...[ nn]]]]]

   Enables or disables breakpoints or displays.

   "enable" by itself enables all breakpoints, just like
   "enable breakpoints". On the other side, "disable" or
   "disable breakpoints" disable all breakpoints.

   You can also specify a space separated list of breakpoint numbers to
   enable or disable specific breakpoints. You can use either
   "enable <id1> ... <idn>" or "enable breakpoints <id1> ... <idn>" and
   the same with "disable".

   If instead of "breakpoints" you specify "display", the command will
   work exactly the same way, but displays will get enabled/disabled
   instead of breakpoints.}
end

.namesObject



106
107
108
# File 'lib/byebug/commands/enable_disable.rb', line 106

def names
  %w((en|dis)able)
end

Instance Method Details

#disable_breakpoints(args) ⇒ Object



97
98
99
# File 'lib/byebug/commands/enable_disable.rb', line 97

def disable_breakpoints(args)
  enable_disable_breakpoints('disable', args)
end

#disable_display(args) ⇒ Object



101
102
103
# File 'lib/byebug/commands/enable_disable.rb', line 101

def disable_display(args)
  enable_disable_display('disable', args)
end

#enable_breakpoints(args) ⇒ Object



89
90
91
# File 'lib/byebug/commands/enable_disable.rb', line 89

def enable_breakpoints(args)
  enable_disable_breakpoints('enable', args)
end

#enable_display(args) ⇒ Object



93
94
95
# File 'lib/byebug/commands/enable_disable.rb', line 93

def enable_display(args)
  enable_disable_display('enable', args)
end

#executeObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/byebug/commands/enable_disable.rb', line 73

def execute
  cmd = @match[1] == 'dis' ? 'disable' : 'enable'

  return errmsg("\"#{cmd}\" must be followed by \"display\", " \
                "\"breakpoints\" or breakpoint ids") unless @match[2]

  args = @match[2].split(/[ \t]+/)
  param = args.shift
  subcmd = Command.find(Subcommands, param)
  if subcmd
    send("#{cmd}_#{subcmd.name}", args)
  else
    send("#{cmd}_breakpoints", args.unshift(param))
  end
end

#regexpObject



69
70
71
# File 'lib/byebug/commands/enable_disable.rb', line 69

def regexp
  /^\s* (dis|en)(?:able)? (?:\s+(.+))? \s*$/x
end