<commit_before>#!/usr/bin/env node
'use strict';

const program = require('commander');
const chalk = require('chalk');
const api = require('../');

program.command('validate <filename>')
  .description('Validates a Swagger API against the Swagger 2.0 schema and spec')
  .option('--no-schema', 'Do NOT validate against the Swagger 2.0 schema')
  .option('--no-spec', 'Do NOT validate against the Swagger 2.0 spec')
  .action((filename, options) => {
    api.validate(filename, options)
      .then(() => {
        console.log(filename, 'is valid');
      })
      .catch(errorHandler);
  });

program.command('bundle <filename>')
  .description('Bundles a multi-file Swagger API into a single file')
  .option('-o, --outfile <filename>', 'The output file')
  .option('-r, --dereference', 'Fully dereference all $ref pointers')
  .option('-f, --format <spaces>', 'Formats the JSON output using the given number of spaces (default is 2)')
  .action((filename, options) => {
    api.bundle(filename, options)
      .then((bundle) => {
        if (options.outfile) {
          console.log('Created %s from %s', options.outfile, filename);
        }
        else {
          // Write the bundled API to stdout
          console.log(bundle);
        }
      })
      .catch(errorHandler);
  });

program
  .version(require('../package').version)
  .option('-d, --debug [filter]', 'Show debug output, optionally filtered (e.g. "*", "swagger:*", etc.)')
  .on('debug', (filter) => {
    process.env.DEBUG = filter || 'swagger:*,json-schema-ref-parser';
  })
  .parse(process.argv);

// Show help if no options were given
if (program.rawArgs.length < 4) {
  program.help();
}

/**
 * Writes error information to stderr and exits with a non-zero code
 *
 * @param {Error} err
 */
function errorHandler (err) {
  console.error(chalk.red(err.stack));
  process.exit(1);
}<commit_msg>Only output the full error stack if the DEBUG environment variable is set<commit_after>#!/usr/bin/env node
'use strict';

const program = require('commander');
const chalk = require('chalk');
const api = require('../');

program.command('validate <filename>')
  .description('Validates a Swagger API against the Swagger 2.0 schema and spec')
  .option('--no-schema', 'Do NOT validate against the Swagger 2.0 schema')
  .option('--no-spec', 'Do NOT validate against the Swagger 2.0 spec')
  .action((filename, options) => {
    api.validate(filename, options)
      .then(() => {
        console.log(filename, 'is valid');
      })
      .catch(errorHandler);
  });

program.command('bundle <filename>')
  .description('Bundles a multi-file Swagger API into a single file')
  .option('-o, --outfile <filename>', 'The output file')
  .option('-r, --dereference', 'Fully dereference all $ref pointers')
  .option('-f, --format <spaces>', 'Formats the JSON output using the given number of spaces (default is 2)')
  .action((filename, options) => {
    api.bundle(filename, options)
      .then((bundle) => {
        if (options.outfile) {
          console.log('Created %s from %s', options.outfile, filename);
        }
        else {
          // Write the bundled API to stdout
          console.log(bundle);
        }
      })
      .catch(errorHandler);
  });

program
  .version(require('../package').version)
  .option('-d, --debug [filter]', 'Show debug output, optionally filtered (e.g. "*", "swagger:*", etc.)')
  .on('debug', (filter) => {
    process.env.DEBUG = filter || 'swagger:*,json-schema-ref-parser';
  })
  .parse(process.argv);

// Show help if no options were given
if (program.rawArgs.length < 4) {
  program.help();
}

/**
 * Writes error information to stderr and exits with a non-zero code
 *
 * @param {Error} err
 */
function errorHandler (err) {
  let errorMessage = process.env.DEBUG ? err.stack : err.message;
  console.error(chalk.red(errorMessage));
  process.exit(1);
}
{'fraction_non_alphanumeric': 0.1691195455719081, 'fraction_numerical': 0.004647560030983733, 'mean_word_length': 3.2108695652173913, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, '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': '4467330', 'n_tokens_mistral': 1218, 'n_tokens_neox': 1194, 'n_words': 345}