class DEBUGGER__::Session

def step_command type, arg

def step_command type, arg
  if type == :until
    leave_subsession [:step, type, arg]
    return
  end
  case arg
  when nil, /\A\d+\z/
    if type == :in && @tc.recorder&.replaying?
      request_tc [:step, type, arg&.to_i]
    else
      leave_subsession [:step, type, arg&.to_i]
    end
  when /\A(back)\z/, /\A(back)\s+(\d+)\z/, /\A(reset)\z/
    if type != :in
      @ui.puts "only `step #{arg}` is supported."
      :retry
    else
      type = $1.to_sym
      iter = $2&.to_i
      request_tc [:step, type, iter]
    end
  else
    @ui.puts "Unknown option: #{arg}"
    :retry
  end
end