<commit_before>#!/usr/bin/env node

import minimist from "minimist";
import usage from "./usage";

import omit from "lodash/omit";

import baseArgs from "./base-args";

export default function(argv, processExit) {
  const args = minimist(argv, {
    ...baseArgs,
    // The first non-option argument is the subcommand:
    stopEarly: true
  });

  if (args["debug-internal"]) require("source-map-support").install();

  let forcedError = false;
  const exit = function(e) {
    if (e && e.message) {
      console.error(e.message);
    }
    if (forcedError) processExit(1);
    else setImmediate(function() {
      if (typeof e === "number") {
        return processExit(e !== 0 ? e : forcedError ? 1 : 0);
      }
      processExit(e ? (typeof e.code === "number" ? e.code : 1) : forcedError ? 1 : 0);
    });
  }

  if (args._[0] === "help" || args.help) {
    let whichHelp = args.help ? args.help : args._[1];
    if (whichHelp === true) whichHelp = false;
    return usage(whichHelp, exit);
  }

  if (args.version) {
    console.log(require("../../package.json").version);
    return;
  }

  if (args.versions) {
    return require("./commands/version")({}, [], exit);
  }

  // launch repl by default
  if (args._.length === 0) args._.push("node-repl");

  const subcommand = args._[0];

  if (subcommand === "index" || subcommand[0] === "_") {
    console.warn("Unknown command\n");
    forcedError = true;
    return usage(false, exit);
  }

  let subcommandFn;
  try {
    subcommandFn = require("./commands/" + subcommand);
    if (subcommandFn.__esModule) subcommandFn = subcommandFn.default;
  } catch (e) {
    if (e.code === "MODULE_NOT_FOUND" && e.message === `Cannot find module './commands/${subcommand}'`) {
      console.warn(`Unknown command '${subcommand}'\n`);
      forcedError = true;
      return usage(false, exit);
    }
    else throw e;
  }

  return subcommandFn(omit(args, "_"), args._.slice(1), exit);
}
<commit_msg>fix(tacoscript/cli): remove block to disallow running internal modules<commit_after>#!/usr/bin/env node

import minimist from "minimist";
import usage from "./usage";

import omit from "lodash/omit";

import baseArgs from "./base-args";

export default function(argv, processExit) {
  const args = minimist(argv, {
    ...baseArgs,
    // The first non-option argument is the subcommand:
    stopEarly: true
  });

  if (args["debug-internal"]) require("source-map-support").install();

  let forcedError = false;
  const exit = function(e) {
    if (e && e.message) {
      console.error(e.message);
    }
    if (forcedError) processExit(1);
    else setImmediate(function() {
      if (typeof e === "number") {
        return processExit(e !== 0 ? e : forcedError ? 1 : 0);
      }
      processExit(e ? (typeof e.code === "number" ? e.code : 1) : forcedError ? 1 : 0);
    });
  }

  if (args._[0] === "help" || args.help) {
    let whichHelp = args.help ? args.help : args._[1];
    if (whichHelp === true) whichHelp = false;
    return usage(whichHelp, exit);
  }

  if (args.version) {
    console.log(require("../../package.json").version);
    return;
  }

  if (args.versions) {
    return require("./commands/version")({}, [], exit);
  }

  // launch repl by default
  if (args._.length === 0) args._.push("node-repl");

  const subcommand = args._[0];

  let subcommandFn;
  try {
    subcommandFn = require("./commands/" + subcommand);
    if (subcommandFn.__esModule) subcommandFn = subcommandFn.default;
  } catch (e) {
    if (e.code === "MODULE_NOT_FOUND" && e.message === `Cannot find module './commands/${subcommand}'`) {
      console.warn(`Unknown command '${subcommand}'\n`);
      forcedError = true;
      return usage(false, exit);
    }
    else throw e;
  }

  return subcommandFn(omit(args, "_"), args._.slice(1), exit);
}

{'fraction_non_alphanumeric': 0.17442778216258878, 'fraction_numerical': 0.006577216521967903, 'mean_word_length': 3.019027484143763, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5919954', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1232, 'n_words': 310}