<commit_before>'use strict';

let yargs = require('yargs'),
  path = require('path'),
  packageInfo = require('../../package'),
  merge = require('lodash.merge'),
  reduce = require('lodash.reduce'),
  cliUtil = require('./cliUtil'),
  fs = require('fs'),
  set = require('lodash.set'),
  graphiteConfig = require('../plugins/graphite').config,
  browsertimeConfig = require('../plugins/browsertime').config,
  metricsConfig = require('../plugins/metrics').config,
  webPageTestConfig = require('../plugins/webpagetest').config,
  slackConfig = require('../plugins/slack').config;

module.exports.parseCommandLine = function parseCommandLine() {
  let parsed = yargs
    .env('SITESPEED_IO')
    .usage('$0 [options] <url>/<file>')
    .require(1, 'urlOrFile')
    .version(() => `${packageInfo.name} ${packageInfo.version}`)
    .option('debug', {
      default: false,
      describe: 'Debug mode logs all internal messages to the console.',
      type: 'boolean'
    })
    .option('verbose', {
      alias: 'v',
      describe: 'Verbose mode prints progress messages to the console. Enter up to three times (-vvv)' +
        ' to increase the level of detail.',
      type: 'count'
    })
    /*
     Browsertime cli options
     */
    .option('browsertime.browser', {
      alias: ['b', 'browser'],
      default: browsertimeConfig.browser,
      describe: 'Choose which Browser to use when you test.',
      choices: ['chrome', 'firefox'],
      group: 'Browser'
    })
    .option('browsertime.iterations', {
      alias: 'n',
      default: browsertimeConfig.iterations,
      describe: 'How many times you want to test each page',
      group: 'Browser'
    })
    .option('browsertime.connectivity.profile', {
      alias: ['c', 'connectivity'],
      default: browsertimeConfig.connectivity.profile,
      choices: ['3g', '3gfast', '3gslow', '3gem', '2g', 'cable', 'native', 'custom'],
      describe: 'The connectivity profile.',
      group: 'Browser'
    })
    .option('browsertime.connectivity.downstreamKbps', {
      default: browsertimeConfig.connectivity.downstreamKbps,
      alias: ['downstreamKbps'],
      describe: 'This option requires --connectivity be set to "custom".',
      group: 'Browser'
    })
    .option('browsertime.connectivity.upstreamKbps', {
      default: browsertimeConfig.connectivity.upstreamKbps,
      alias: ['upstreamKbps'],
      describe: 'This option requires --connectivity be set to "custom".',
      group: 'Browser'
    })
    .option('browsertime.connectivity.latency', {
      default: browsertimeConfig.connectivity.latency,
      alias: ['latency'],
      describe: 'This option requires --connectivity be set to "custom".',
      group: 'Browser'
    })
    .option('browsertime.connectivity.tsproxy.port', {
      default: browsertimeConfig.connectivity.tsproxy.port,
      describe: 'The port used for TSProxy',
      group: 'Browser'
    })
    .option('browsertime.connectivity.engine', {
      default: browsertimeConfig.connectivity.engine,
      choices: ['tc', 'tsproxy', 'external'],
      describe: 'The engine for connectivity. TSProxy needs Python 2.7. TC (Linux Traffic Control) needs tc work but will only setup upload and latency. Use external if you set the connectivity outside of Browsertime.',
      group: 'Browser'
    })
    .option('browsertime.pageCompleteCheck', {
      describe: 'Supply a Javascript that decides when the browser is finished loading the page and can start to collect metrics. The Javascript snippet is repeatedly queried to see if page has completed loading (indicated by the script returning true). Use it to fetch timings happening after the loadEventEnd.',
      group: 'Browser'
    })
    .option('browsertime.script', {
      describe: 'Add custom Javascript that collect metrics and run after the page has finished loading. Note that --script can be passed multiple times if you want to collect multiple metrics. The metrics will automatically be pushed to the summary/detailed summary and each individual page + sent to Graphite/InfluxDB.',
      alias: ['script'],
      group: 'Browser'
    })
    .option('browsertime.selenium.url', {
      describe: 'Configure the path to the Selenium server when fetching timings using browsers. If not configured the supplied NodeJS/Selenium version is used.',
      group: 'Browser'
    })
    .option('browsertime.viewPort', {
      default: browsertimeConfig.viewPort,
      describe: 'The browser view port size WidthxHeight like 400x300',
      group: 'Browser'
    })
    .option('browsertime.userAgent', {
      describe: 'The full User Agent string, defaults to the User Agent used by the browsertime.browser option.',
      group: 'Browser'
    })
    .option('browsertime.preScript', {
      alias: 'preScript',
      describe: 'Selenium script(s) to run before you test your URL (use it for login, warm the cache, etc). Note that --preScript can be passed multiple times.',
      group: 'Browser'
    })
    .option('browsertime.postScript', {
      alias: 'postScript',
      describe: 'Selenium script(s) to run after you test your URL (use it for logout etc). Note that --postScript can be passed multiple times.',
      group: 'Browser'
    })
    .option('browsertime.delay', {
      describe: 'Delay between runs, in milliseconds. Use it if your web server needs to rest between runs :)',
      group: 'Browser'
    })
    .option('browsertime.speedIndex', {
      alias: 'speedIndex',
      type: 'boolean',
      describe: 'Calculate SpeedIndex. Requires FFMpeg and python dependencies',
      group: 'Browser'
    })
    .option('browsertime.video', {
      alias: 'video',
      type: 'boolean',
      describe: 'Record a video. Requires FFMpeg to be installed',
      group: 'Browser'
    })
    .option('browsertime.preURL', {
      alias: 'preURL',
      describe: 'A URL that will be accessed first by the browser before the URL that you wanna analyze. Use it to fill the cache.',
      group: 'Browser'
    })
    .option('browsertime.userTimingWhitelist', {
      alias: 'userTimingWhitelist',
      describe: 'This option takes a regex that will whitelist which userTimings to capture in the results. All userTimings are captured by default. T',
      group: 'Browser'
    })
    .option('browsertime.firefox.preference', {
      describe: 'Extra command line arguments to pass Firefox preferences by the format key:value ' +
      'To add multiple preferences, repeat --browsertime.firefox.preference once per argument.',
       group: 'Browser'
    })
    .option('browsertime.firefox.includeResponseBodies', {
      describe: 'Include response bodies in HAR when using Firefox.',
      type: 'boolean',
      group: 'Browser'
    })
    .option('browsertime.chrome.args', {
      describe: 'Extra command line arguments to pass to the Chrome process (e.g. --no-sandbox). ' +
      'To add multiple arguments to Chrome, repeat --browsertime.chrome.args once per argument.',
      group: 'Browser'
    })
    .option('browsertime.chrome.collectTracingEvents', {
      type: 'boolean',
      describe: 'Collect Chromes traceCategories',
      group: 'Browser'
    })
    // legacy naming of collectTracingEvents
    .option('browsertime.chrome.dumpTraceCategoriesLog', {
      type: 'boolean',
      describe: false,
      group: 'Browser'
    })
    .option('browsertime.chrome.collectNetLog', {
      type: 'boolean',<commit_msg>hide deprecated option<commit_after>'use strict';

let yargs = require('yargs'),
  path = require('path'),
  packageInfo = require('../../package'),
  merge = require('lodash.merge'),
  reduce = require('lodash.reduce'),
  cliUtil = require('./cliUtil'),
  fs = require('fs'),
  set = require('lodash.set'),
  graphiteConfig = require('../plugins/graphite').config,
  browsertimeConfig = require('../plugins/browsertime').config,
  metricsConfig = require('../plugins/metrics').config,
  webPageTestConfig = require('../plugins/webpagetest').config,
  slackConfig = require('../plugins/slack').config;

module.exports.parseCommandLine = function parseCommandLine() {
  let parsed = yargs
    .env('SITESPEED_IO')
    .usage('$0 [options] <url>/<file>')
    .require(1, 'urlOrFile')
    .version(() => `${packageInfo.name} ${packageInfo.version}`)
    .option('debug', {
      default: false,
      describe: 'Debug mode logs all internal messages to the console.',
      type: 'boolean'
    })
    .option('verbose', {
      alias: 'v',
      describe: 'Verbose mode prints progress messages to the console. Enter up to three times (-vvv)' +
        ' to increase the level of detail.',
      type: 'count'
    })
    /*
     Browsertime cli options
     */
    .option('browsertime.browser', {
      alias: ['b', 'browser'],
      default: browsertimeConfig.browser,
      describe: 'Choose which Browser to use when you test.',
      choices: ['chrome', 'firefox'],
      group: 'Browser'
    })
    .option('browsertime.iterations', {
      alias: 'n',
      default: browsertimeConfig.iterations,
      describe: 'How many times you want to test each page',
      group: 'Browser'
    })
    .option('browsertime.connectivity.profile', {
      alias: ['c', 'connectivity'],
      default: browsertimeConfig.connectivity.profile,
      choices: ['3g', '3gfast', '3gslow', '3gem', '2g', 'cable', 'native', 'custom'],
      describe: 'The connectivity profile.',
      group: 'Browser'
    })
    .option('browsertime.connectivity.downstreamKbps', {
      default: browsertimeConfig.connectivity.downstreamKbps,
      alias: ['downstreamKbps'],
      describe: 'This option requires --connectivity be set to "custom".',
      group: 'Browser'
    })
    .option('browsertime.connectivity.upstreamKbps', {
      default: browsertimeConfig.connectivity.upstreamKbps,
      alias: ['upstreamKbps'],
      describe: 'This option requires --connectivity be set to "custom".',
      group: 'Browser'
    })
    .option('browsertime.connectivity.latency', {
      default: browsertimeConfig.connectivity.latency,
      alias: ['latency'],
      describe: 'This option requires --connectivity be set to "custom".',
      group: 'Browser'
    })
    .option('browsertime.connectivity.tsproxy.port', {
      default: browsertimeConfig.connectivity.tsproxy.port,
      describe: 'The port used for TSProxy',
      group: 'Browser'
    })
    .option('browsertime.connectivity.engine', {
      default: browsertimeConfig.connectivity.engine,
      choices: ['tc', 'tsproxy', 'external'],
      describe: 'The engine for connectivity. TSProxy needs Python 2.7. TC (Linux Traffic Control) needs tc work but will only setup upload and latency. Use external if you set the connectivity outside of Browsertime.',
      group: 'Browser'
    })
    .option('browsertime.pageCompleteCheck', {
      describe: 'Supply a Javascript that decides when the browser is finished loading the page and can start to collect metrics. The Javascript snippet is repeatedly queried to see if page has completed loading (indicated by the script returning true). Use it to fetch timings happening after the loadEventEnd.',
      group: 'Browser'
    })
    .option('browsertime.script', {
      describe: 'Add custom Javascript that collect metrics and run after the page has finished loading. Note that --script can be passed multiple times if you want to collect multiple metrics. The metrics will automatically be pushed to the summary/detailed summary and each individual page + sent to Graphite/InfluxDB.',
      alias: ['script'],
      group: 'Browser'
    })
    .option('browsertime.selenium.url', {
      describe: 'Configure the path to the Selenium server when fetching timings using browsers. If not configured the supplied NodeJS/Selenium version is used.',
      group: 'Browser'
    })
    .option('browsertime.viewPort', {
      default: browsertimeConfig.viewPort,
      describe: 'The browser view port size WidthxHeight like 400x300',
      group: 'Browser'
    })
    .option('browsertime.userAgent', {
      describe: 'The full User Agent string, defaults to the User Agent used by the browsertime.browser option.',
      group: 'Browser'
    })
    .option('browsertime.preScript', {
      alias: 'preScript',
      describe: 'Selenium script(s) to run before you test your URL (use it for login, warm the cache, etc). Note that --preScript can be passed multiple times.',
      group: 'Browser'
    })
    .option('browsertime.postScript', {
      alias: 'postScript',
      describe: 'Selenium script(s) to run after you test your URL (use it for logout etc). Note that --postScript can be passed multiple times.',
      group: 'Browser'
    })
    .option('browsertime.delay', {
      describe: 'Delay between runs, in milliseconds. Use it if your web server needs to rest between runs :)',
      group: 'Browser'
    })
    .option('browsertime.speedIndex', {
      alias: 'speedIndex',
      type: 'boolean',
      describe: 'Calculate SpeedIndex. Requires FFMpeg and python dependencies',
      group: 'Browser'
    })
    .option('browsertime.video', {
      alias: 'video',
      type: 'boolean',
      describe: 'Record a video. Requires FFMpeg to be installed',
      group: 'Browser'
    })
    .option('browsertime.preURL', {
      alias: 'preURL',
      describe: 'A URL that will be accessed first by the browser before the URL that you wanna analyze. Use it to fill the cache.',
      group: 'Browser'
    })
    .option('browsertime.userTimingWhitelist', {
      alias: 'userTimingWhitelist',
      describe: 'This option takes a regex that will whitelist which userTimings to capture in the results. All userTimings are captured by default. T',
      group: 'Browser'
    })
    .option('browsertime.firefox.preference', {
      describe: 'Extra command line arguments to pass Firefox preferences by the format key:value ' +
      'To add multiple preferences, repeat --browsertime.firefox.preference once per argument.',
       group: 'Browser'
    })
    .option('browsertime.firefox.includeResponseBodies', {
      describe: 'Include response bodies in HAR when using Firefox.',
      type: 'boolean',
      group: 'Browser'
    })
    .option('browsertime.chrome.args', {
      describe: 'Extra command line arguments to pass to the Chrome process (e.g. --no-sandbox). ' +
      'To add multiple arguments to Chrome, repeat --browsertime.chrome.args once per argument.',
      group: 'Browser'
    })
    .option('browsertime.chrome.collectTracingEvents', {
      type: 'boolean',
      describe: 'Collect Chromes traceCategories',
      group: 'Browser'
    })
    // legacy naming of collectTracingEvents
    .option('browsertime.chrome.dumpTraceCategoriesLog', {
      type: 'boolean',
      describe: false
    })
    .option('browsertime.chrome.collectNetLog', {
      type: 'boolean',
{'fraction_non_alphanumeric': 0.12300006750826976, 'fraction_numerical': 0.0020252480928913794, 'mean_word_length': 3.188295165394402, 'pattern_counts': {'":': 0, '<': 7, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7513557', 'n_tokens_mistral': 4262, 'n_tokens_neox': 4166, 'n_words': 1329}