<commit_before>#!/usr/bin / env node
const yargs = require('yargs')
const retyped = require('./retyped_node')

const a = yargs
  .usage('$0 <cmd> [args]')
  .command(
    'generate [files...]',
    'Generate BuckleScript interfaces from a file'
  )
  .help()
  .argv

console.log(a)<commit_msg>Basic CLI<commit_after>#!/usr/bin / env node

const fs = require('fs')
const path = require('path')
const yargs = require('yargs')
const retyped = require('./retyped_node')

yargs
  .usage('retyped')
  .version(require('./package.json').version)
  .command('compile [files...]', 'Generate BuckleScript interfaces from a file', {}, compileFiles)
  .option('flow-typed', {
    describe: 'Generate interfaces from the flow-typed directory'
  })
  .demandCommand(1, '')
  .help()
  .argv

function compileFiles ({ files }) {
  files.forEach(compileFile)
}

function compileFile (filePath) {
  return new Promise((resolve, reject) => {
    fs.readFile(filePath, (err, data) => {
      if (err) return reject(err)

      const fileName = path.basename(filePath)
      const [moduleName, _, bsCode] = retyped.compile(fileName, data.toString())

      const writeDirName = path.dirname(filePath)
      const writeFileName = path.join(writeDirName, moduleName + '.re')

      console.log(`Writing ${filePath} -> ${writeFileName}`)
      fs.writeFile(writeFileName, bsCode, err => {
        if (err) return reject(err)

        resolve()
      })
    })
  })
}
{'fraction_non_alphanumeric': 0.15997229916897507, 'fraction_numerical': 0.0013850415512465374, 'mean_word_length': 3.558359621451104, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, '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': '7398305', 'n_tokens_mistral': 478, 'n_tokens_neox': 462, 'n_words': 110}