<commit_before>import os
import strutils
import nre
import options
import tables

import types
import server
import objects
import querying
import verbs
import builtins
import persist
import rdstdin

let
  world = loadWorld("min")
  player = world.getObjects()[7]

try:
  world.check()
except InvalidWorldError:
  let exception = getCurrentException()
  echo "Invalid world: " & exception.msg & "."

player.output = proc(obj: MObject, msg: string) =
  echo msg

proc myEscape(s: string): string =
  s.replace("\"", "\\\"")

proc stripNewLines(s: string): string =
  s.replace("\n", "")

while true:
  while world.numTasks() > 0:
    world.tick()
  world.persist()

  var command = ""

  try:
    command = readLineFromStdin("> ").strip()
  except IOError:
    break

  if command.contains("<>"):
    discard os.execShellCmd("$EDITOR edit.tmp")
    command = command.replace("<>", readFile("edit.tmp").myEscape().stripNewLines())

  let match = command.match(re"vedit (.+?):(.*)")

  if match.isSome:
    try:
      let matches = match.get.captures
      let verbname = matches[1]

      let objs = player.query(matches[0].strip())
      let obj = objs[0]

      let verb = obj.getVerb(verbname)
      if verb == nil:
        raise newException(Exception, "Verb doesn't exist")

      let code = verb.code

      writeFile("edit.tmp", code)
      discard os.execShellCmd("$EDITOR edit.tmp -c \"set filetype=lisp\"")
      let newCode = readFile("edit.tmp")

      verb.setCode(newCode)
      echo "Succesfully edited verb '$1'" % verbname

<commit_msg>Update setCode call in main.nim<commit_after>import os
import strutils
import nre
import options
import tables

import types
import server
import objects
import querying
import verbs
import builtins
import persist
import rdstdin

let
  world = loadWorld("min")
  player = world.getObjects()[7]

try:
  world.check()
except InvalidWorldError:
  let exception = getCurrentException()
  echo "Invalid world: " & exception.msg & "."

player.output = proc(obj: MObject, msg: string) =
  echo msg

proc myEscape(s: string): string =
  s.replace("\"", "\\\"")

proc stripNewLines(s: string): string =
  s.replace("\n", "")

while true:
  while world.numTasks() > 0:
    world.tick()
  world.persist()

  var command = ""

  try:
    command = readLineFromStdin("> ").strip()
  except IOError:
    break

  if command.contains("<>"):
    discard os.execShellCmd("$EDITOR edit.tmp")
    command = command.replace("<>", readFile("edit.tmp").myEscape().stripNewLines())

  let match = command.match(re"vedit (.+?):(.*)")

  if match.isSome:
    try:
      let matches = match.get.captures
      let verbname = matches[1]

      let objs = player.query(matches[0].strip())
      let obj = objs[0]

      let verb = obj.getVerb(verbname)
      if verb == nil:
        raise newException(Exception, "Verb doesn't exist")

      let code = verb.code

      writeFile("edit.tmp", code)
      discard os.execShellCmd("$EDITOR edit.tmp -c \"set filetype=lisp\"")
      let newCode = readFile("edit.tmp")

      verb.setCode(newCode, player, compileIt = true)
      echo "Succesfully edited verb '$1'" % verbname


{'fraction_non_alphanumeric': 0.14049586776859505, 'fraction_numerical': 0.003814367450731087, 'mean_word_length': 3.346685082872928, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1719454', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1012, 'n_words': 273}