lib/byebug/commands/condition.rb in byebug-5.0.0 vs lib/byebug/commands/condition.rb in byebug-6.0.0

- old
+ new

@@ -8,16 +8,33 @@ # Adds the ability to stop on breakpoints only under certain conditions. # class ConditionCommand < Command include Helpers::ParseHelper - self.allow_in_post_mortem = false + self.allow_in_post_mortem = true - def regexp + def self.regexp /^\s* cond(?:ition)? (?:\s+(\d+)(?:\s+(.*))?)? \s*$/x end + def self.description + <<-EOD + cond[ition] <n>[ expr] + + #{short_description} + + 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 + + def self.short_description + 'Sets conditions on breakpoints' + end + def execute return puts(help) unless @match[1] breakpoints = Byebug.breakpoints.sort_by(&:id) return errmsg(pr('condition.errors.no_breakpoints')) if breakpoints.empty? @@ -31,19 +48,8 @@ unless syntax_valid?(@match[2]) return errmsg(pr('break.errors.not_changed', expr: @match[2])) end breakpoint.expr = @match[2] - end - - def description - <<-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 end end