<commit_before>require 'coffee-script/register'
path = require 'path'
fs = require 'fs'
colors = require 'colors'
read = require 'read'
nomnom = require 'nomnom'
toml = require 'toml'
_ = require 'underscore'

# Private: Split a list the first instance of an element
#
# * `target` Element of the list you want to split at.
# * `items` {Array} to split.
#
# Returns the original {Array} otherwise returns an {Array} of two {Array}s
# where the first contains everything prior to the `target` element and the
# second contains everything after. The `target` element isn't includes
splitAt = (target, items) ->
  index = items.indexOf target
  if index > -1
    beginning = items.slice(0, index)
    end = items.slice(index + 1)
    [beginning, end]
  else
    [items, []]

# Private: Merge toml config at a path with some opts.
#
# If `tomlPath` exists, read it and merge the resulting object with opts.
#
# * `tomlPath`: {String} to a possible toml config file.
# * `opts`: {Object} of parsed command line options.
#
# Returns an {Object} of the merged config.
mergeConfig = (tomlPath, opts) ->
  if tomlPath and fs.existsSync tomlPath
    _.extend toml.parse(fs.readFileSync(tomlPath)), opts
  else
    opts

# Separate all args after `--` so we can pass those on to the quest.
[args, questOpts] = splitAt '--', process.argv.slice(2)

opts = nomnom()
  .script 'sqlquest'
  .option 'user', abbr: 'u', help: 'Database username'
  .option 'pass', abbr: 'P', help: 'Database password'
  .option 'host', abbr: 'H', help: 'Database host'
  .option 'port', abbr: 'p', help: 'Database port', default: 5432
  .option 'url', abbr: 'U', help: """Connection URL:
                                     (postgres://user:pass@host:port/db)"""
  .option 'db', abbr: 'd', help: 'Database name'
  .option 'quests', abbr: 'q', help: 'Where to find quests'
  .option('splitter',
    abbr: 's',
    default: 'http://sqlformat.org/api/v1/split',
    help: 'Splitter API URL to use')
  .option('config',
    abbr: 'c',<commit_msg>Remove default for sqlsplit cmd opt<commit_after>require 'coffee-script/register'
path = require 'path'
fs = require 'fs'
colors = require 'colors'
read = require 'read'
nomnom = require 'nomnom'
toml = require 'toml'
_ = require 'underscore'

# Private: Split a list the first instance of an element
#
# * `target` Element of the list you want to split at.
# * `items` {Array} to split.
#
# Returns the original {Array} otherwise returns an {Array} of two {Array}s
# where the first contains everything prior to the `target` element and the
# second contains everything after. The `target` element isn't includes
splitAt = (target, items) ->
  index = items.indexOf target
  if index > -1
    beginning = items.slice(0, index)
    end = items.slice(index + 1)
    [beginning, end]
  else
    [items, []]

# Private: Merge toml config at a path with some opts.
#
# If `tomlPath` exists, read it and merge the resulting object with opts.
#
# * `tomlPath`: {String} to a possible toml config file.
# * `opts`: {Object} of parsed command line options.
#
# Returns an {Object} of the merged config.
mergeConfig = (tomlPath, opts) ->
  if tomlPath and fs.existsSync tomlPath
    _.extend toml.parse(fs.readFileSync(tomlPath)), opts
  else
    opts

# Separate all args after `--` so we can pass those on to the quest.
[args, questOpts] = splitAt '--', process.argv.slice(2)

opts = nomnom()
  .script 'sqlquest'
  .option 'user', abbr: 'u', help: 'Database username'
  .option 'pass', abbr: 'P', help: 'Database password'
  .option 'host', abbr: 'H', help: 'Database host'
  .option 'port', abbr: 'p', help: 'Database port', default: 5432
  .option 'url', abbr: 'U', help: """Connection URL:
                                     (postgres://user:pass@host:port/db)"""
  .option 'db', abbr: 'd', help: 'Database name'
  .option 'quests', abbr: 'q', help: 'Where to find quests'
  .option('splitter',
    abbr: 's',
    help: 'Splitter API URL to use [http://sqlformat.org/api/v1/split]')
  .option('config',
    abbr: 'c',
{'fraction_non_alphanumeric': 0.14065606361829025, 'fraction_numerical': 0.0044731610337972166, 'mean_word_length': 3.5480225988700567, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4583819', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1315, 'n_words': 489}