<commit_before>defmodule Mix.Tasks.Step6File do
  def run(_) do
    env = Mal.Env.initialize()
    Mal.Env.merge(env, Mal.Core.namespace)
    bootstrap(env)
    main(env)
  end

  def bootstrap(env) do
    read_eval_print("(def! not (fn* (a) (if a false true)))", env)<commit_msg>Add support for load-file, eval and *ARGV*<commit_after>defmodule Mix.Tasks.Step6File do
  def run(args) do
    env = Mal.Env.initialize()
    Mal.Env.merge(env, Mal.Core.namespace)
    bootstrap(args, env)
    load_file(args, env)
    main(env)
  end

  defp load_file([], _env), do: nil
  defp load_file([file_name | args], env) do
    read_eval_print("""
      (load-file "#{file_name}")
      """, env)
    exit(:normal)
  end

  defp bootstrap(args, env) do
    # not:
    read_eval_print("""
      (def! not
        (fn* (a) (if a false true)))
      """, env)

    # load-file:
    read_eval_print("""
      (def! load-file
        (fn* (f)
          (eval (read-string (str "(do " (slurp f) ")")))))
      """, env)

    Mal.Env.set(env, "eval", fn [ast] ->
      eval(ast, env)
    end)

    case args do
      [_file_name | rest] -> Mal.Env.set(env, "*ARGV*", rest)
      [] -> Mal.Env.set(env, "*ARGV*", [])
    end
{'fraction_non_alphanumeric': 0.17412935323383086, 'fraction_numerical': 0.001658374792703151, 'mean_word_length': 2.5710059171597632, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '2117586', 'n_tokens_mistral': 465, 'n_tokens_neox': 454, 'n_words': 108}