<commit_before>#!/usr/bin/env node

import program from 'commander';
import { openPath, openFile } from './utils.js';
import { compile } from './sel.js';

const pathToJSCode = async (path, options) => {
  const baseCode = await openFile('../src/base.sel');
  let selCode;
  try {
    selCode = await openPath(path);
  } catch (e) {
    console.log(e);
    process.exit(1);
  }
  try {
    return await compile(`
      ${options.removeBase ? '' : baseCode}
      ${selCode}
    `, options.compiler);
  } catch (e) {
    console.log(e);
    process.exit(1);
  }
};

program
  .command('compile [path]')
  .description('Compile the given SEL file to Javascript')
  .alias('c')
  .option('-rb, --remove-base', 'Set to true to remove base SEL lib')
  .option('-co, --compiler [type]', 'Select which compiler to use ([JavaScript]/LetFreeJavaScript/Python)', 'JavaScript')
  .action(async (path, options) => {
    console.log(await pathToJSCode(path, options));
  });

program
  .command('run [path]')
  .description('Compile the given SEL file to Javascript and eval it')
  .alias('r')
  .option('-rb, --remove-base', 'Set to true to remove base SEL lib')
  .option('-co, --compiler [type]', 'Select which compiler to use ([JavaScript]/LetFreeJavaScript/Python)', 'JavaScript')
  .action(async (path, options) => {
    eval(await pathToJSCode(path, options)); //eslint-disable-line
  });

if (!process.argv.slice(2).length) {
  program.outputHelp();
}
program.parse(process.argv);<commit_msg>compiler is not actual option when running a script, and shouldn't be.<commit_after>#!/usr/bin/env node

import program from 'commander';
import { openPath, openFile } from './utils.js';
import { compile } from './sel.js';

const pathToJSCode = async (path, options) => {
  const baseCode = await openFile('../src/base.sel');
  let selCode;
  try {
    selCode = await openPath(path);
  } catch (e) {
    console.log(e);
    process.exit(1);
  }
  try {
    return await compile(`
      ${options.removeBase ? '' : baseCode}
      ${selCode}
    `, options.compiler);
  } catch (e) {
    console.log(e);
    process.exit(1);
  }
};

program
  .command('compile [path]')
  .description('Compile the given SEL file to Javascript')
  .alias('c')
  .option('-rb, --remove-base', 'Set to true to remove base SEL lib')
  .option('-co, --compiler [type]', 'Select which compiler to use ([JavaScript]/LetFreeJavaScript/Python)', 'JavaScript')
  .action(async (path, options) => {
    console.log(await pathToJSCode(path, options));
  });

program
  .command('run [path]')
  .description('Compile the given SEL file to Javascript and eval it')
  .alias('r')
  .option('-rb, --remove-base', 'Set to true to remove base SEL lib')
  .action(async (path, options) => {
    eval(await pathToJSCode(path, options)); //eslint-disable-line
  });

if (!process.argv.slice(2).length) {
  program.outputHelp();
}
program.parse(process.argv);
{'fraction_non_alphanumeric': 0.17406260749914002, 'fraction_numerical': 0.0020639834881320948, 'mean_word_length': 3.6232114467408585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1719388', 'n_tokens_mistral': 978, 'n_tokens_neox': 955, 'n_words': 256}