<commit_before>const program = require('commander');

const _parse = program.parse.bind(program);

program.parse = (args) => {
  _parse(args);

  const requiredOptions = program.options.filter(opt => opt.required && opt.required !== 0);

  const options = requiredOptions.map(option => {
    return option.long.replace('--', '');
  });

  if (!!options.some(element => !Object.getOwnPropertyNames(program).includes(element))) {
    throw new Error(`Missing a required flag`);
  }

}

module.exports = program;<commit_msg>add better display for missing flag<commit_after>const program = require('commander');

const _parse = program.parse.bind(program);

program.parse = (args) => {
  _parse(args);

  const requiredOptions = program.options.filter(opt => opt.required && opt.required !== 0);

  const options = requiredOptions.map(option => {
    return option.long.replace('--', '');
  });

  const match = !options.some(element => !Object.getOwnPropertyNames(program).includes(element));

  if (!match) {
    const missing = options.filter(match => {
      return !Object.getOwnPropertyNames(program).includes(match);
    })
    throw new Error(`Missing required flag: --${missing}`);
  }
}

module.exports = program;
{'fraction_non_alphanumeric': 0.16406890894175555, 'fraction_numerical': 0.0016406890894175555, 'mean_word_length': 4.446428571428571, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '2257038', 'n_tokens_mistral': 358, 'n_tokens_neox': 352, 'n_words': 74}