<commit_before>const console = require('console'); // Stubbed in tests by proxyquire
const fs = require('fs');
const optimist = require('optimist');
const os = require('os');
const spawnArgs = require('spawn-args');
const spawnSync = require('cross-spawn').sync;

const configUtils = require('./config-utils');
const Dredd = require('./dredd');
const interactiveConfig = require('./interactive-config');
const logger = require('./logger');
const { applyLoggingOptions } = require('./configuration');
const { ignorePipeErrors } = require('./common');
const { spawn } = require('./child-process');

const packageData = require('../package.json');

class DreddCommand {
  constructor(options = {}, cb) {
    this.cb = cb;
    this.finished = false;
    ({ exit: this.exit, custom: this.custom } = options);

    this.setExitOrCallback();

    if (!this.custom) { this.custom = {}; }

    if (!this.custom.cwd || typeof this.custom.cwd !== 'string') {
      this.custom.cwd = process.cwd();
    }

    if (!this.custom.argv || !Array.isArray(this.custom.argv)) {
      this.custom.argv = [];
    }

    // Fixes https://github.com/apiaryio/dredd/issues/1030
    process.stdin.on('error', (err) => {
      logger.error(`Error in stdin: ${err}`);
    });
  }

  setOptimistArgv() {
    this.optimist = optimist(this.custom.argv, this.custom.cwd);
    this.cliArgv = this.optimist.argv;

    this.optimist.usage(`\
Usage:
  $ dredd init

Or:
  $ dredd <path or URL to API description document> <URL of tested server> [OPTIONS]

Example:
  $ dredd ./api-description.apib http://127.0.0.1:3000 --dry-run\
`)
      .options(Dredd.options)
      .wrap(80);

    this.argv = this.optimist.argv;
    this.argv = applyLoggingOptions(this.argv);<commit_msg>refactor: remove unnecessary stdin error handler<commit_after>const console = require('console'); // Stubbed in tests by proxyquire
const fs = require('fs');
const optimist = require('optimist');
const os = require('os');
const spawnArgs = require('spawn-args');
const spawnSync = require('cross-spawn').sync;

const configUtils = require('./config-utils');
const Dredd = require('./dredd');
const interactiveConfig = require('./interactive-config');
const logger = require('./logger');
const { applyLoggingOptions } = require('./configuration');
const { ignorePipeErrors } = require('./common');
const { spawn } = require('./child-process');

const packageData = require('../package.json');

class DreddCommand {
  constructor(options = {}, cb) {
    this.cb = cb;
    this.finished = false;
    ({ exit: this.exit, custom: this.custom } = options);

    this.setExitOrCallback();

    if (!this.custom) { this.custom = {}; }

    if (!this.custom.cwd || typeof this.custom.cwd !== 'string') {
      this.custom.cwd = process.cwd();
    }

    if (!this.custom.argv || !Array.isArray(this.custom.argv)) {
      this.custom.argv = [];
    }
  }

  setOptimistArgv() {
    this.optimist = optimist(this.custom.argv, this.custom.cwd);
    this.cliArgv = this.optimist.argv;

    this.optimist.usage(`\
Usage:
  $ dredd init

Or:
  $ dredd <path or URL to API description document> <URL of tested server> [OPTIONS]

Example:
  $ dredd ./api-description.apib http://127.0.0.1:3000 --dry-run\
`)
      .options(Dredd.options)
      .wrap(80);

    this.argv = this.optimist.argv;
    this.argv = applyLoggingOptions(this.argv);
{'fraction_non_alphanumeric': 0.17390011890606422, 'fraction_numerical': 0.008323424494649227, 'mean_word_length': 3.541160593792173, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4361464', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1072, 'n_words': 232}