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

//const insertTable = require('mdast-contributors')
//const mdast       = require('mdast')
const CSON            = require('CSON')
const minimist        = require('minimist')
const path            = require('path')
const getContributors = require('./lib/')
const fs              = require('fs')
const _               = require('lodash')
const renderTemplate  = require('./lib/render-template')
const cwd         = process.cwd()
const defaults    = _.partialRight(_.assign, function(value, other) {
  if (value == null) return other
    if (_.isObject(value))
    value = _.assign(other, value)
  return value
})

const optsfileName = path.join(cwd, '.contributors')
const defaultOptions = {
  ask: true,
  config: optsfileName,
  dirname: cwd,
  fields: 'name,github',
  format: 'json',
  tryGithub: true,
  write: true
}
const aliasOptions = {
    h: 'help',
    a: 'ask',
    c: 'config',
    d: 'dirname',
    e: 'fields',
    f: 'format',
    g: 'tryGithub',
    i: 'info',
    t: 'template',
    w: 'write'
}
var options = defaultOptions
try {
  options = defaults(CSON.requireFile(optsfileName), options)
} catch(e){}

var argv = minimist(process.argv.slice(2), {
  alias: aliasOptions,
  default: options
})

//console.log('argv0', argv)
if (argv.config !== options.config) try {
  //the user specify the conf file
  //console.log('load', argv.config)
  var opts = CSON.requireFile(argv.config)
  defaults(opts, options)
  argv = minimist(process.argv.slice(2), {
    alias: aliasOptions,
    default: opts
  })
} catch(e){}

if (argv.fields) {
  argv.fields = argv.fields.split(',')
}

if (argv.info) {
  console.log(argv)
}

if (argv.help) {
  var pkg = CSON.requireFile(path.join(__dirname, 'package.json'))
  var file = require('read-file')
  var usage = file.readFileSync(path.join(__dirname, 'usage.txt')) 
  console.log('Version:', pkg.version)
  console.log(usage)
} else {
  getContributors(argv, function (err, contributors) {<commit_msg>* show configuration info on stderr<commit_after>#!/usr/bin/env node

//const insertTable = require('mdast-contributors')
//const mdast       = require('mdast')
const CSON            = require('CSON')
const minimist        = require('minimist')
const path            = require('path')
const getContributors = require('./lib/')
const fs              = require('fs')
const _               = require('lodash')
const renderTemplate  = require('./lib/render-template')
const cwd         = process.cwd()
const defaults    = _.partialRight(_.assign, function(value, other) {
  if (value == null) return other
    if (_.isObject(value))
    value = _.assign(other, value)
  return value
})

const optsfileName = path.join(cwd, '.contributors')
const defaultOptions = {
  ask: true,
  config: optsfileName,
  dirname: cwd,
  fields: 'name,github',
  format: 'json',
  tryGithub: true,
  write: true
}
const aliasOptions = {
    h: 'help',
    a: 'ask',
    c: 'config',
    d: 'dirname',
    e: 'fields',
    f: 'format',
    g: 'tryGithub',
    i: 'info',
    t: 'template',
    w: 'write'
}
var options = defaultOptions
try {
  options = defaults(CSON.requireFile(optsfileName), options)
} catch(e){}

var argv = minimist(process.argv.slice(2), {
  alias: aliasOptions,
  default: options
})

//console.log('argv0', argv)
if (argv.config !== options.config) try {
  //the user specify the conf file
  //console.log('load', argv.config)
  var opts = CSON.requireFile(argv.config)
  defaults(opts, options)
  argv = minimist(process.argv.slice(2), {
    alias: aliasOptions,
    default: opts
  })
} catch(e){}

if (argv.fields) {
  argv.fields = argv.fields.split(',')
}

if (argv.info) {
  console.error(argv)
}

if (argv.help) {
  var pkg = CSON.requireFile(path.join(__dirname, 'package.json'))
  var file = require('read-file')
  var usage = file.readFileSync(path.join(__dirname, 'usage.txt')) 
  console.log('Version:', pkg.version)
  console.log(usage)
} else {
  getContributors(argv, function (err, contributors) {
{'fraction_non_alphanumeric': 0.15901148277583624, 'fraction_numerical': 0.0014977533699450823, 'mean_word_length': 3.3840262582056893, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6280306', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1332, 'n_words': 323}