<commit_before>'use strict'

const options = require('./options')
const fs = require('fs')
const extend = require('extend')
const packageJson = require('../../package.json')
const colors = require('colors/safe')

module.exports = function (program) {
  const start = program
    .command('start')
    .description('run the Solid server')

  options
    .filter((option) => !option.hide)
    .forEach((option) => {
      var name = '--' + option.name
      if (!option.flag) {
        name += ' [value]'
      }
      start.option(name, option.help)
    })

  start.option('-v, --verbose', 'Print the logs to console')

  start.action((opts) => {
    let argv = extend({}, opts)

    fs.readFile(process.cwd() + '/config.json', (err, file) => {
      // No file exists, not a problem
      if (err) {
        console.log(colors.cyan.bold('TIP'), 'create a config.json: `$ solid init`')
      } else {
        // Overwrite current configs with config file
        const config = JSON.parse(file)
        Object.keys(config).forEach((option) => {
          // however, some flags have priority from command line
          if (option === 'port' ||
              option === 'sslCert' ||
              option === 'owner' ||
              option === 'sslKey') {
            argv[option] = argv[option] || config[option]
          } else {
            argv[option] = config[option]
          }
        })
      }

      bin(argv)
    })
  })
}<commit_msg>change priority in mergin config and flags<commit_after>'use strict'

const options = require('./options')
const fs = require('fs')
const extend = require('extend')
const packageJson = require('../../package.json')
const colors = require('colors/safe')

module.exports = function (program) {
  const start = program
    .command('start')
    .description('run the Solid server')

  options
    .filter((option) => !option.hide)
    .forEach((option) => {
      var name = '--' + option.name
      if (!option.flag) {
        name += ' [value]'
      }
      start.option(name, option.help)
    })

  start.option('-v, --verbose', 'Print the logs to console')

  start.action((opts) => {
    let argv = extend({}, opts)

    fs.readFile(process.cwd() + '/config.json', (err, file) => {
      // No file exists, not a problem
      if (err) {
        console.log(colors.cyan.bold('TIP'), 'create a config.json: `$ solid init`')
      } else {
        // Use flags with priority over config file
        const config = JSON.parse(file)
        Object.keys(config).forEach((option) => {
          argv[option] = argv[option] || config[option]
        })
      }

      bin(argv)
    })
  })
}
{'fraction_non_alphanumeric': 0.16698292220113853, 'fraction_numerical': 0.0, 'mean_word_length': 2.3074027603513176, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '4353952', 'n_tokens_mistral': 790, 'n_tokens_neox': 774, 'n_words': 199}