<commit_before>#! /usr/bin/env node
const suggest = require('../src')
const parseArg = (arg) => {
  try {
    return JSON.parse(arg)
  } catch (e) {
    try {
      // Eval is used here to easily cast data types, eslint can shutup
      // eslint-disable-next-line
      return eval(arg)
    } catch (e) { return arg.toString() }
  }
}

// Need to pre process the inputs to cast them into their actual types?
let [ output, ...inputs ] = process.argv.slice(2).reverse().map(parseArg)
inputs = inputs.reverse()

let outputInput, outputReturn

if (/\(.*?\) => .*/.test(`${output}`)) {
  [, outputInput, outputReturn] = /\((.*?)\) => (.*)/.exec(`${output}`)

  const args = outputInput.split(/, ?/).map(parseArg).filter(a => a)
  const ret = parseArg(outputReturn)

  output = { args, ret }
}

suggest(inputs, output)<commit_msg>[fix #1] Log a usage message if no output/inputs given<commit_after>#! /usr/bin/env node
const { grey, bold } = require('chalk')
const suggest = require('../src')
const parseArg = (arg) => {
  try {
    return JSON.parse(arg)
  } catch (e) {
    try {
      // Eval is used here to easily cast data types, eslint can shutup
      // eslint-disable-next-line
      return eval(arg)
    } catch (e) { return arg.toString() }
  }
}

if (process.argv.length < 3) {
  console.log(`
${bold('ramda-suggest')}: Missing arguments

  Try: ${grey('ramda-suggest input1 input2 output2')}
       ${grey('ramda-suggest true')}
`)
  process.exit(0)
}

// Need to pre process the inputs to cast them into their actual types?
let [ output, ...inputs ] = process.argv.slice(2).reverse().map(parseArg)
inputs = inputs.reverse()

let outputInput, outputReturn

if (/\(.*?\) => .*/.test(`${output}`)) {
  [, outputInput, outputReturn] = /\((.*?)\) => (.*)/.exec(`${output}`)

  const args = outputInput.split(/, ?/).map(parseArg).filter(a => a)
  const ret = parseArg(outputReturn)

  output = { args, ret }
}

suggest(inputs, output)
{'fraction_non_alphanumeric': 0.18937048503611972, 'fraction_numerical': 0.0041279669762641896, 'mean_word_length': 3.2060737527114966, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 11, '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': '5790288', 'n_tokens_mistral': 670, 'n_tokens_neox': 650, 'n_words': 175}