<commit_before>
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

#include <readline/readline.h>
#include <readline/history.h>

#include "src/tools/reader.h"
#include "src/turbine/command.h"

char* usage(void);
void crash(char* msg);
void error(turbine_code code, reader_line line);

int
main(int argc, char* argv[])
{
  if (argc < 2)
    crash(usage());

  char* filename = argv[1];

  // Use reader to read input file

  bool result = reader_init();
  assert(result);

  long reader = reader_read(filename);
  if (reader == -1)
  {
    printf("turbine-batch: could not read: %s\n", filename);
    exit(1);
  }

  // Insert commands into turbine

  turbine_code code = turbine_init();
  if (code != TURBINE_SUCCESS)
    crash("could not initialize turbine!");

  reader_line line = reader_next(reader);
  while (line.line)
  {
    printf("line: %i cmd: %s\n", line.number, line.line);
    code = turbine_command(line.line);
    if (code != TURBINE_SUCCESS)
      error(code, line);
    line = reader_next(reader);
  }

  // Run?

  // Cleanup
  reader_free(reader);
  reader_finalize();
}

char*
usage()
{
  return "usage: batch <file>";
}

void
crash(char* msg)
{
  printf("turbine-batch: %s\n", msg);<commit_msg>Checkin current state - will probably remove this<commit_after>
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

#include <readline/readline.h>
#include <readline/history.h>

#include "src/tools/reader.h"
#include "src/turbine/command.h"

char* usage(void);
void crash(char* msg);
void error(turbine_code code, reader_line line);

int
main(int argc, char* argv[])
{
  if (argc < 2)
    crash(usage());

  char* filename = argv[1];

  // Use reader to read input file
  reader_init();
  long reader_id = reader_read(file);
  if (reader_id == -1)
  {
    char msg[1024];
    sprintf(msg, "could not read: %s", file);
    crash(msg);
  }

  bool result = reader_init();
  assert(result);

  long reader = reader_read(filename);
  if (reader == -1)
  {
    printf("turbine-batch: could not read: %s\n", filename);
    exit(1);
  }

  // Insert commands into turbine
  while (true)
  {
    char* line = reader_next(reader_id);
    if (!line)
      break;
    turbine_command(line);
  }

  // Set up turbine
  turbine_code code = turbine_init();
  if (code != TURBINE_SUCCESS)
    crash("could not initialize turbine!");

  reader_line line = reader_next(reader);
  while (line.line)
  {
    printf("line: %i cmd: %s\n", line.number, line.line);
    code = turbine_command(line.line);
    if (code != TURBINE_SUCCESS)
      error(code, line);
    line = reader_next(reader);
  }

  // Run?

  // Cleanup
  reader_free(reader);
  reader_finalize();
}

char*
usage()
{
  return "usage: batch <file>";
}

void
crash(char* msg)
{
  printf("turbine-batch: %s\n", msg);
{'fraction_non_alphanumeric': 0.1580246913580247, 'fraction_numerical': 0.004585537918871252, 'mean_word_length': 3.5448717948717947, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, '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': '4693931', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1041, 'n_words': 257}