<commit_before>// Copyright © 2014-2016 <NAME>, All Rights Reserved.

// Distributed under the MIT License
// See accompanying file LICENSE

#include <cstdio>
#include <deque>
#include <iostream>
#include <vector>
#include <fstream>
#include <string>

#include "cppformat/format.h"
#include "arrow/tokenizer.hpp"
#include "arrow/command.hpp"

void help(char* binary_path) {
  std::printf(
    "Usage: \x1b[0;36m%s\x1b[0m [<command>] [<options>] <input-file>\n",
    binary_path);

  std::printf("\n");
}

int main(int argc, char** argv, char** environ) {
    // Register available commands
  std::deque<std::shared_ptr<arrow::Command>> commands;
  commands.push_back(std::make_shared<arrow::command::Parse>());
  commands.push_back(std::make_shared<arrow::command::Tokenize>());

  // Check for a specified command
  std::vector<char*> args(argv, argv + argc);
  unsigned cmd_index = 0;
  bool found = false;
  if (args.size() >= 2) {
    std::string a1(args[1]);
    if (a1.size() >= 3 && a1[0] == '-' && a1[1] == '-') {
      // The first arguments is `--[...]`
      auto command_name = a1.substr(2);
      for (unsigned i = 0; i < commands.size(); ++i) {
        if (command_name == commands[i]->name()) {
          found = true;
          cmd_index = i;
          break;
        }
      }

      if (found) {
        // Remove the command argument
        args.erase(args.begin() + 1);
      }
    }
  } else {
    // Show help
    // help(argv[0], commands);
    help(argv[0]);
    return 0;
  }

  if (!found) {
    std::string a1(args[1]);
    if (a1.substr(2) == "help" || a1.substr(1) == "h") {
      // Show help
      // help(argv[0], commands);
      help(argv[0]);
      return 0;
    }
  }

  // Get the requested command
  auto cmd = commands.at(cmd_index);

  // Run the received command<commit_msg>Improve help display<commit_after>// Copyright © 2014-2016 <NAME>, All Rights Reserved.

// Distributed under the MIT License
// See accompanying file LICENSE

#include <cstdio>
#include <deque>
#include <iostream>
#include <vector>
#include <fstream>
#include <string>

#include "cppformat/format.h"
#include "arrow/tokenizer.hpp"
#include "arrow/command.hpp"

void help(char* binary_path,
          const std::deque<std::shared_ptr<arrow::Command>>& commands) {
  std::printf(
    "Usage: \x1b[0;36m%s\x1b[0m [<command>] [<options>] <input-file>\n",
    binary_path);

  std::printf("Commands:\n");
  for (auto& cmd : commands) {
    std::printf("  \x1b[0;33m--%-10s\x1b[0m", cmd->name());
    std::printf("%s", cmd->description());
    std::printf("\n");
  }

  std::printf("  \x1b[0;33m--%-10s\x1b[0m", "help");
  std::printf("Display this help information");
  std::printf("\n");

  std::printf("\n");
}

int main(int argc, char** argv, char** environ) {
    // Register available commands
  std::deque<std::shared_ptr<arrow::Command>> commands;
  commands.push_back(std::make_shared<arrow::command::Parse>());
  commands.push_back(std::make_shared<arrow::command::Tokenize>());

  // Check for a specified command
  std::vector<char*> args(argv, argv + argc);
  unsigned cmd_index = 0;
  bool found = false;
  if (args.size() >= 2) {
    std::string a1(args[1]);
    if (a1.size() >= 3 && a1[0] == '-' && a1[1] == '-') {
      // The first arguments is `--[...]`
      auto command_name = a1.substr(2);
      for (unsigned i = 0; i < commands.size(); ++i) {
        if (command_name == commands[i]->name()) {
          found = true;
          cmd_index = i;
          break;
        }
      }

      if (found) {
        // Remove the command argument
        args.erase(args.begin() + 1);
      }
    }
  } else {
    // Show help
    help(argv[0], commands);
    return 0;
  }

  if (!found) {
    std::string a1(args[1]);
    if (a1.substr(2) == "help" || a1.substr(1) == "h") {
      // Show help
      help(argv[0], commands);
      return 0;
    }
  }

  // Get the requested command
  auto cmd = commands.at(cmd_index);

  // Run the received command
{'fraction_non_alphanumeric': 0.18924352852475496, 'fraction_numerical': 0.023624026137220408, 'mean_word_length': 2.8905180840664713, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 43, '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': '1245848', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1377, 'n_words': 321}