<commit_before>module.exports = function(stdin, stdout, stderr, env, opt) {
  if (opt['--version'] || opt['-v']) {
    return function(callback) {
      var meta = require('../package.json');
      stdout.write(meta.name + ' ' + meta.version + '\n');
      callback(0);
    };
  } else if (opt.hash) {
    return function(callback) {
      require('./read-form')(stdin, opt, function(error, form) {
        var normalized = require('commonform-normalize')(form);
        stdout.write(normalized.root + '\n');
        callback(0);
      });
    };
  } else if (opt.render) {
    return function(callback) {
      var numberStyle = opt['--number'];
      var styles = require('./numberings');
      if (!styles.hasOwnProperty(numberStyle)) {
        stderr.write([
          '"' + numberStyle + '" is not a valid numbering style.',
          'Valid styles are ' +
          require('english-list')(
            'and',
            Object.keys(styles).map(function(s) {
              return '"' + s + '"';
            })
          ) +
          '.'
        ].join('\n') + '\n');
        callback(1);
        return;
      } else {
        opt.numbering = require(styles[numberStyle])
      }
      require('./read-form')(stdin, opt, function(error, form) {
        var format = opt['--format'];
        var transform = require('./transform-for-format')(format, opt);
        if (typeof transform === 'function') {
          try {
            stdout.write(transform(form));
            callback(0);
          } catch (e) {
            stderr.write(e.message);
            callback(1);
          }
        } else {
          stderr.write([
            '"' + format + '" is not a valid format.',
            'Valid formats are ' +
            require('english-list')('and', transform.map(function(s) {
              return '"' + s + '"';
            })) +
            '.'
          ].join('\n') + '\n');
          callback(1);
        }
      });
    };
  } else if (opt.lint) {
    return function(callback) {
      require('./read-form')(stdin, opt, function(error, form) {
        var issues = require('commonform-lint')(form);
        issues.forEach(function(issue) {
          stdout.write(issue.message + '\n');
        });
        callback(issues.length === 0 ? 0 : 1);
      });
    };
  } else if (opt.critique) {
    return function(callback) {
      require('./read-form')(stdin, opt, function(error, form) {
        var issues = require('commonform-critique')(form);
        issues.forEach(function(issue) {
          stdout.write(issue.message + '\n');
        });
        callback(issues.length === 0 ? 0 : 1);
      });
    };
  } else if (opt.share) {
    return function(callback) {
      require('./read-form')(stdin, opt, function(error, form) {
        var options = {
          hostname: 'api.commonform.org',
          post: 443,
          path: '/forms',
          method: 'POST',
          headers: {
            'Content-Type': 'application/json'
          }
        };
        var request = require('https')
          .request(options, function(response) {
            console.log(
                'https://commonform.org/#' +
                response.headers.location.replace('/forms/', '')
            );
            callback(0);
          });
        request
          .on('error', function(error) {
            console.error(error.message);
            callback(1);
          })
          .end(JSON.stringify(form));
      });
    };
  } else {
    return undefined;
  }
};<commit_msg>Remove `commonform share`<commit_after>module.exports = function(stdin, stdout, stderr, env, opt) {
  if (opt['--version'] || opt['-v']) {
    return function(callback) {
      var meta = require('../package.json');
      stdout.write(meta.name + ' ' + meta.version + '\n');
      callback(0);
    };
  } else if (opt.hash) {
    return function(callback) {
      require('./read-form')(stdin, opt, function(error, form) {
        var normalized = require('commonform-normalize')(form);
        stdout.write(normalized.root + '\n');
        callback(0);
      });
    };
  } else if (opt.render) {
    return function(callback) {
      var numberStyle = opt['--number'];
      var styles = require('./numberings');
      if (!styles.hasOwnProperty(numberStyle)) {
        stderr.write([
          '"' + numberStyle + '" is not a valid numbering style.',
          'Valid styles are ' +
          require('english-list')(
            'and',
            Object.keys(styles).map(function(s) {
              return '"' + s + '"';
            })
          ) +
          '.'
        ].join('\n') + '\n');
        callback(1);
        return;
      } else {
        opt.numbering = require(styles[numberStyle])
      }
      require('./read-form')(stdin, opt, function(error, form) {
        var format = opt['--format'];
        var transform = require('./transform-for-format')(format, opt);
        if (typeof transform === 'function') {
          try {
            stdout.write(transform(form));
            callback(0);
          } catch (e) {
            stderr.write(e.message);
            callback(1);
          }
        } else {
          stderr.write([
            '"' + format + '" is not a valid format.',
            'Valid formats are ' +
            require('english-list')('and', transform.map(function(s) {
              return '"' + s + '"';
            })) +
            '.'
          ].join('\n') + '\n');
          callback(1);
        }
      });
    };
  } else if (opt.lint) {
    return function(callback) {
      require('./read-form')(stdin, opt, function(error, form) {
        var issues = require('commonform-lint')(form);
        issues.forEach(function(issue) {
          stdout.write(issue.message + '\n');
        });
        callback(issues.length === 0 ? 0 : 1);
      });
    };
  } else if (opt.critique) {
    return function(callback) {
      require('./read-form')(stdin, opt, function(error, form) {
        var issues = require('commonform-critique')(form);
        issues.forEach(function(issue) {
          stdout.write(issue.message + '\n');
        });
        callback(issues.length === 0 ? 0 : 1);
      });
    };
  } else {
    return undefined;
  }
};
{'fraction_non_alphanumeric': 0.1751530776667741, 'fraction_numerical': 0.004672897196261682, 'mean_word_length': 1.7464601769911505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '6388100', 'n_tokens_mistral': 1817, 'n_tokens_neox': 1787, 'n_words': 339}