class Byebug::ConditionCommand

:nodoc:

def execute

def execute
  if not @match[1]
    errmsg "\"condition\" must be followed by breakpoint number and expression\n"
  else
    breakpoints = Byebug.breakpoints.sort_by{|b| b.id }
    largest = breakpoints.inject(0) do |tally, b|
      tally = b.id if b.id > tally
    end
    if 0 == largest
      print "No breakpoints have been set.\n"
      return
    end
    pos = get_int(@match[1], "Condition", 1, largest)
    return unless pos
    breakpoints.each do |b|
      if b.id == pos
        b.expr = @match[2].empty? ? nil : @match[2]
        break
      end
    end
  end
end

def help(cmd)

def help(cmd)
  %{
    Condition breakpoint-number expression
y breakpoint number N to break only if COND is true. N is an integer and
s an expression to be evaluated whenever breakpoint N is reached. If the
string is used, the condition is removed.
  }
end

def help_command

def help_command
  'condition'
end

def regexp

def regexp
  /^\s* cond(?:ition)? (?:\s+(\d+)\s*(.*))?$/ix
end