lib/byebug/commands/condition.rb in byebug-4.0.5 vs lib/byebug/commands/condition.rb in byebug-5.0.0
- old
+ new
@@ -1,22 +1,25 @@
require 'byebug/command'
+require 'byebug/helpers/parse'
module Byebug
#
# Implements conditions on breakpoints.
#
# Adds the ability to stop on breakpoints only under certain conditions.
#
class ConditionCommand < Command
+ include Helpers::ParseHelper
+
self.allow_in_post_mortem = false
def regexp
/^\s* cond(?:ition)? (?:\s+(\d+)(?:\s+(.*))?)? \s*$/x
end
def execute
- return puts(self.class.help) unless @match[1]
+ return puts(help) unless @match[1]
breakpoints = Byebug.breakpoints.sort_by(&:id)
return errmsg(pr('condition.errors.no_breakpoints')) if breakpoints.empty?
pos, err = get_int(@match[1], 'Condition', 1)
@@ -30,23 +33,17 @@
end
breakpoint.expr = @match[2]
end
- class << self
- def names
- %w(condition)
- end
+ def description
+ <<-EOD
+ cond[ition] <n>[ expr]
- def description
- prettify <<-EOD
- cond[ition] <n>[ expr]
-
- Specify breakpoint number <n> to break only if <expr> is true. <n> is
- an integer and <expr> is an expression to be evaluated whenever
- breakpoint <n> is reached. If no expression is specified, the
- condition is removed.
- EOD
- end
+ Specify breakpoint number <n> to break only if <expr> is true. <n> is
+ an integer and <expr> is an expression to be evaluated whenever
+ breakpoint <n> is reached. If no expression is specified, the condition
+ is removed.
+ EOD
end
end
end