<commit_before>defmodule Exedra.REPL do
  def start(user_charlist) do
    username = String.Chars.to_string user_charlist
    spawn fn ->
      Process.flag(:trap_exit, true) # TODO: determine if necessary
      IO.puts "Hello " <> username <> "!"
      loop(username)
    end
  end

  def loop(username) do
    prompt = "> "

    prompt
    |> IO.gets
    |> String.Chars.to_string
    |> String.trim_trailing
    |> String.split(" ")
    |> Exedra.Commands.execute(username)

    loop(username)
  end

end<commit_msg>Add repl handling user interrupts gracefully<commit_after>defmodule Exedra.REPL do
  def start(user_charlist) do
    username = String.Chars.to_string user_charlist
    spawn fn ->
      Process.flag(:trap_exit, true) # TODO: determine if necessary
      IO.puts "Hello " <> username <> "!"
      loop(username)
    end
  end

  def loop(username) do
    prompt = "> "

    case IO.gets prompt do
      {:error, reason} ->
        # TODO log
        IO.puts username <> " lost connection: " <> Atom.to_string(reason)
      input ->
        input
        |> String.Chars.to_string
        |> String.trim_trailing
        |> String.split(" ")
        |> Exedra.Commands.execute(username)
        loop(username)
    end


  end

end
{'fraction_non_alphanumeric': 0.11217948717948718, 'fraction_numerical': 0.0, 'mean_word_length': 2.440771349862259, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 24, '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': '5161804', 'n_tokens_mistral': 418, 'n_tokens_neox': 391, 'n_words': 90}