<commit_before><commit_msg>Create a yabf application specific to configfile<commit_after>import { AbstractApplication } from 'yabf'
import program from 'commander'

import { Command } from './command'
import { LogUtils } from '../shared/utils'

export class TermApplication extends AbstractApplication {
  buildInstructions() {
    return [
      { provide: TermApplication, dependencies: [] }
    ]
  }

  register(command, deps = []) {
    if (!(command.prototype instanceof Command)) {
      return null
    }

    this.commands = [command, ...(this.commands || [])]
    this.injectorService.provide(command, deps, false)
  }

  start() {
    if (!Array.isArray(this.commands) || this.commands.length < 1) {
      LogUtils.log({ message: `No command found in Term Application` })
      LogUtils.log({ type: 'error', message: `Application failed to initialize` })
      return
    }

    for (const commandClass of this.commands) {
      const controller = this.injectorService.get(commandClass)

      let command = program.command(controller.commandName)

      if (controller.alias != null) {
        command = command.alias(controller.alias)
      }

      if (controller.alias != null && controller.description.length > 0) {
        command = command.description(controller.description)
      }

      if (Array.isArray(controller.options)) {
        for (const [option, optionDesc] of controller.options) {
          command = command.option(option, optionDesc)
        }
      }

      if ('run' in controller && typeof controller.run === 'function') {
        command.action(controller.run.bind(controller))
      }
    }

    program.parse(process.argv)
  }
}
{'fraction_non_alphanumeric': 0.12335329341317365, 'fraction_numerical': 0.0011976047904191617, 'mean_word_length': 3.0071942446043165, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '1755561', 'n_tokens_mistral': 463, 'n_tokens_neox': 451, 'n_words': 111}