<commit_before>const minimist = require('minimist')
const { build, printCommands, printWtf } = require('gluegun')
const header = require('../brand/header')
const { isNil, isEmpty } = require('ramda')
const exitCodes = require('../lib/exitCodes')

/**
 * Kick off a run.
 *
 * @param  {array} argv An array of command line arguments.
 * @return {RunContext} The gluegun RunContext
 */
module.exports = async function run (argv) {
  // create a runtime
  const runtime = build()
    .brand('ignite')
    .configFile('ignite/ignite.toml')
    .loadDefault(`${__dirname}/../plugins/default`)
    .loadAll(`${process.cwd()}/node_modules`, { matching: 'ignite-*', hidden: true })
    .token('commandName', 'cliCommand')
    .token('commandDescription', 'cliDescription')
    .token('extensionName', 'contextExtension')
    .createRuntime()

  // parse the commandLine line
  const commandLine = minimist(argv.slice(2))

  // are we asking for --version|-version|-v and nothing else?
  const showVersionNumber = isEmpty(commandLine._) && commandLine.version || commandLine.v
  if (showVersionNumber) {
    runtime.run({ rawCommand: 'version' })
    process.exit(exitCodes.OK)
  }

  // wtf mode shows problems with plugins, commands, and extensions
  if (commandLine.wtf) {
    printWtf(runtime)
    process.exit(exitCodes.OK)
  }

  // run the command
  const context = await runtime.run()

  // print the commands (TODO: but not if we just ran i guess)
  if (isNil(context.plugin) || isNil(context.command)) {
    header()
    printCommands(context)
  }

  if (context.error) {
    console.dir(context.error)
  }<commit_msg>Cleans up the logic for showing --version.<commit_after>const minimist = require('minimist')
const { build, printCommands, printWtf } = require('gluegun')
const header = require('../brand/header')
const { isNil, isEmpty } = require('ramda')
const exitCodes = require('../lib/exitCodes')

/**
 * Kick off a run.
 *
 * @param  {array} argv An array of command line arguments.
 * @return {RunContext} The gluegun RunContext
 */
module.exports = async function run (argv) {
  // create a runtime
  const runtime = build()
    .brand('ignite')
    .configFile('ignite/ignite.toml')
    .loadDefault(`${__dirname}/../plugins/default`)
    .loadAll(`${process.cwd()}/node_modules`, { matching: 'ignite-*', hidden: true })
    .token('commandName', 'cliCommand')
    .token('commandDescription', 'cliDescription')
    .token('extensionName', 'contextExtension')
    .createRuntime()

  // parse the commandLine line
  const commandLine = minimist(argv.slice(2))

  // should we show the version number & jet?
  const hasNoArguments = isEmpty(commandLine._)
  const hasVersionOption = commandLine.version || commandLine.v
  if (hasNoArguments && hasVersionOption) {
    runtime.run({ rawCommand: 'version' })
    process.exit(exitCodes.OK)
  }

  // wtf mode shows problems with plugins, commands, and extensions
  if (commandLine.wtf) {
    printWtf(runtime)
    process.exit(exitCodes.OK)
  }

  // run the command
  const context = await runtime.run()

  // print the commands (TODO: but not if we just ran i guess)
  if (isNil(context.plugin) || isNil(context.command)) {
    header()
    printCommands(context)
  }

  if (context.error) {
    console.dir(context.error)
  }
{'fraction_non_alphanumeric': 0.1444647201946472, 'fraction_numerical': 0.0006082725060827251, 'mean_word_length': 3.7528901734104045, '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': '2244193', 'n_tokens_mistral': 1018, 'n_tokens_neox': 1008, 'n_words': 264}