<commit_before>// tslint:disable: no-console
import { manifest } from "../manifest";
import { versionBump } from "../version-bump";
import { VersionBumpOptions } from "../version-bump-options";
import { helpText } from "./help";
import { parseArgs } from "./parse-args";

enum ExitCode {
  Success = 0,
  SytaxError = 1,
  RuntimeError = 2,
}

/**
 * The main entry point of the CLI
 *
 * @param args - The command-line arguments (e.g. ["major", "--preid=alpha", "-ctpa"])
 */
export async function main(args: string[]): Promise<void> {
  try {
    let { help, version, options } = parseArgs(args);

    if (help) {
      // Show the help text and exit
      console.log(helpText);
      process.exit(ExitCode.Success);
    }
    else if (version) {
      // Show the version number and exit
      console.log(manifest.version);
      process.exit(ExitCode.Success);
    }
    else {
      await bump(options);
    }
  }
  catch (error) {
    // There was an error parsing the command-line args
    console.error((error as Error).message);
    console.error(helpText);
    process.exit(ExitCode.SytaxError);
  }
}

async function bump(options: VersionBumpOptions): Promise<void> {
  try {
    let results = await versionBump(options);
    console.log("\n\nRESULTS:", results, "\n\n");
  }
  catch (error) {
    console.error((error as Error).stack || (error as Error).message);
    process.exit(ExitCode.RuntimeError);
  }
}
<commit_msg>Only print stack traces when DEBUG or NODE_ENV is set<commit_after>// tslint:disable: no-console
import { manifest } from "../manifest";
import { versionBump } from "../version-bump";
import { VersionBumpOptions } from "../version-bump-options";
import { helpText } from "./help";
import { parseArgs } from "./parse-args";

enum ExitCode {
  Success = 0,
  SytaxError = 1,
  RuntimeError = 2,
}

/**
 * The main entry point of the CLI
 *
 * @param args - The command-line arguments (e.g. ["major", "--preid=alpha", "-ctpa"])
 */
export async function main(args: string[]): Promise<void> {
  try {
    let { help, version, options } = parseArgs(args);

    if (help) {
      // Show the help text and exit
      console.log(helpText);
      process.exit(ExitCode.Success);
    }
    else if (version) {
      // Show the version number and exit
      console.log(manifest.version);
      process.exit(ExitCode.Success);
    }
    else {
      await bump(options);
    }
  }
  catch (error) {
    // There was an error parsing the command-line args
    console.error((error as Error).message);
    console.error(helpText);
    process.exit(ExitCode.SytaxError);
  }
}

async function bump(options: VersionBumpOptions): Promise<void> {
  try {
    let results = await versionBump(options);
    console.log("\n\nRESULTS:", results, "\n\n");
  }
  catch (error) {
    let message = (error as Error).message;

    if (process.env.DEBUG || process.env.NODE_ENV === "development") {
      message = (error as Error).stack || message;
    }

    console.error(message);
    process.exit(ExitCode.RuntimeError);
  }
}

{'fraction_non_alphanumeric': 0.14811165845648605, 'fraction_numerical': 0.0019704433497536944, 'mean_word_length': 2.9921363040629094, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5584300', 'n_tokens_mistral': 969, 'n_tokens_neox': 943, 'n_words': 258}