<commit_before>
testsuite = require './testsuite'
runner = require './runner'
subprocess = require './subprocess'

debug = require('debug')('fbp-spec:cli')

## Main
parse = (args) ->
  program = require 'commander'

  program
    .arguments('<suites>')
    .action( (suites) -> program.suites = suites )
    .option('--address <URL>', 'Address of runtime to connect to', String, 'ws://localhost:3569')
    .option('--secret <secret>', 'Runtime secret', String, null)
    .option('--command <command>', 'Command to launch runtime under test', String, null)
    .parse(process.argv)

  return program


startRuntime = (options, callback) ->

  if not options.command # we're not responsible for starting it
    callback null
    return null
  subprocessOptions = {}
  return subprocess.start options.command, subprocessOptions, callback

hasErrors = (suites) ->
  failures = 0
  for s in suites
    for c in s.cases
      failures += 1 if c.error
  return failures > 0

runOptions = (options, onUpdate, callback) ->
  suites = testsuite.getSuitesSync options.suites
  child = null

  cleanReturn = (err) -><commit_msg>fbp-spec: Make local test directory optional<commit_after>
testsuite = require './testsuite'
runner = require './runner'
subprocess = require './subprocess'

debug = require('debug')('fbp-spec:cli')

## Main
parse = (args) ->
  program = require 'commander'

  program
    .arguments('<suites>')
    .action( (suites) -> program.suites = suites )
    .option('--address <URL>', 'Address of runtime to connect to', String, 'ws://localhost:3569')
    .option('--secret <secret>', 'Runtime secret', String, null)
    .option('--command <command>', 'Command to launch runtime under test', String, null)
    .parse(process.argv)

  return program


startRuntime = (options, callback) ->

  if not options.command # we're not responsible for starting it
    callback null
    return null
  subprocessOptions = {}
  return subprocess.start options.command, subprocessOptions, callback

hasErrors = (suites) ->
  failures = 0
  for s in suites
    for c in s.cases
      failures += 1 if c.error
  return failures > 0

runOptions = (options, onUpdate, callback) ->
  suites = []
  suites = testsuite.getSuitesSync options.suites if options.suites
  child = null

  cleanReturn = (err) ->
{'fraction_non_alphanumeric': 0.13333333333333333, 'fraction_numerical': 0.006100217864923747, 'mean_word_length': 3.582834331337325, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, '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': '5345582', 'n_tokens_mistral': 695, 'n_tokens_neox': 680, 'n_words': 218}