<commit_before>import program from 'commander'

function wrapper(res) {
  if (res.catch) {
    res.catch(err => {
      console.error(err.stack)
    })
  }

  return res
}

function basicCliWrapper(fnName) {
  return async function (maybeServices, ...args) {
    const { getEnvironment } = require('../environment')

    const opts = args.length === 0 ? maybeServices : args[args.length - 1]
    const otherArgs = args.slice(0, args.length - 1)
    const envName = opts.environment

    const returnVal = await wrapper(getEnvironment(envName)[fnName](
      Array.isArray(maybeServices) && maybeServices.length === 0
        ? undefined
        : maybeServices,
      ...otherArgs,
    ))

    if (returnVal != null) {
      console.log(returnVal)
    }
  }
}

function lazyRequire(path) {
  return function (...args) {
    return wrapper(require(path)(...args))
  }
}

program
  .command('launch [services...]')
  .option('-e, --environment [env]', 'set the environment name to be used [dev]', 'dev')
  .description('Launches the given services in an environment')
  .action(lazyRequire('./launch'))
  .on('--help', () => console.log(`
  This will prompt you for the services that you want to bring up.
  You can optionally provide the names of services to bring up which will disable the interactive prompt.
  `))

program
  .command('ps')
  .option('-e, --environment [env]', 'set the environment name to be used [dev]', 'dev')
  .description('Lists the running services for an environment')
  .action(basicCliWrapper('ps'))

program<commit_msg>Add destroy command to CLI<commit_after>import program from 'commander'

function wrapper(res) {
  if (res.catch) {
    res.catch(err => {
      console.error(err.stack)
    })
  }

  return res
}

function basicCliWrapper(fnName) {
  return async function (maybeServices, ...args) {
    const { getEnvironment } = require('../environment')

    const opts = args.length === 0 ? maybeServices : args[args.length - 1]
    const otherArgs = args.slice(0, args.length - 1)
    const envName = opts.environment

    const returnVal = await wrapper(getEnvironment(envName)[fnName](
      Array.isArray(maybeServices) && maybeServices.length === 0
        ? undefined
        : maybeServices,
      ...otherArgs,
    ))

    if (returnVal != null) {
      console.log(returnVal)
    }
  }
}

function lazyRequire(path) {
  return function (...args) {
    return wrapper(require(path)(...args))
  }
}

program
  .command('launch [services...]')
  .option('-e, --environment [env]', 'set the environment name to be used [dev]', 'dev')
  .description('Launches the given services in an environment')
  .action(lazyRequire('./launch'))
  .on('--help', () => console.log(`
  This will prompt you for the services that you want to bring up.
  You can optionally provide the names of services to bring up which will disable the interactive prompt.
  `))

program
  .command('destroy')
  .option('-e, --environment [env]', 'set the environment name to be used [dev]', 'dev')
  .option('-f, --force', 'don\'t prompt before removing the environment')
  .description('Destroys an environment and all related data and services')
  .action(basicCliWrapper('destroy'))
  .on('--help', () => console.log(`
  This will destroy an entire environment and all of its data and services.

  Examples:
    $ navy destroy # destroy "dev" environment
    $ navy destroy -e dev # destroy "dev" environment
    $ navy destroy -e test # destroy "test" environment
  `))

program
  .command('ps')
  .option('-e, --environment [env]', 'set the environment name to be used [dev]', 'dev')
  .description('Lists the running services for an environment')
  .action(basicCliWrapper('ps'))

program
{'fraction_non_alphanumeric': 0.1406207827260459, 'fraction_numerical': 0.002699055330634278, 'mean_word_length': 3.36, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '1311581', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1075, 'n_words': 342}