<commit_before>fs = require 'fs'
#yaml = require 'js-yaml'

module.exports.CLI = class CLI
   constructor : (argv) ->
      @file = '[]'
      @ports =
         stub : 80
         admin : 81
      fileOptionIndex = argv.indexOf('--file') + 1
      if fileOptionIndex
         filename = argv[fileOptionIndex]
         file = fs.readFileSync filename, 'utf8'
         extension = filename.replace /^.*\.([a-zA-Z0-9]+)$/, '$1'
         if file
            switch extension
               when 'json'
                  try
                     @file = JSON.parse file
                  catch e
                     console.error "Couldn't load #{filename} due to syntax errors:"
                     console.dir e
                     @file = []
               when 'yaml','yml'
                  @file = yaml.load file

      stubOptionIndex = process.argv.indexOf('--stub') + 1
      @ports.stub = parseInt(process.argv[stubOptionIndex]) ? @ports.stub if stubOptionIndex

      adminOptionIndex = process.argv.indexOf('--admin') + 1
      @ports.admin = parseInt(process.argv[adminOptionIndex]) ? @ports.admin if adminOptionIndex<commit_msg>made js-yaml an optional dependency<commit_after>fs = require 'fs'

module.exports.CLI = class CLI
   constructor : (argv) ->
      @file = '[]'
      @ports =
         stub : 80
         admin : 81
      fileOptionIndex = argv.indexOf('--file') + 1
      if fileOptionIndex
         filename = argv[fileOptionIndex]
         file = fs.readFileSync filename, 'utf8'
         extension = filename.replace /^.*\.([a-zA-Z0-9]+)$/, '$1'
         if file
            switch extension
               when 'json'
                  try
                     @file = JSON.parse file
                  catch e
                     console.error "Couldn't load #{filename} due to syntax errors:"
                     console.dir e
                     @file = []
               when 'yaml','yml'
                  @file = require('js-yaml').yaml.load file

      stubOptionIndex = process.argv.indexOf('--stub') + 1
      @ports.stub = parseInt(process.argv[stubOptionIndex]) ? @ports.stub if stubOptionIndex

      adminOptionIndex = process.argv.indexOf('--admin') + 1
      @ports.admin = parseInt(process.argv[adminOptionIndex]) ? @ports.admin if adminOptionIndex
{'fraction_non_alphanumeric': 0.11938997821350762, 'fraction_numerical': 0.009586056644880174, 'mean_word_length': 1.6916764361078547, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2795486', 'n_tokens_mistral': 648, 'n_tokens_neox': 620, 'n_words': 152}