<commit_before>import { GluegunCommand } from '../../domain/command'
import { GluegunToolbox } from '../../domain/toolbox'

const NewCommand: GluegunCommand = {
  name: 'new',
  alias: ['n', 'create'],
  description: 'Creates a new gluegun cli',
  hidden: false,
  run: async (toolbox: GluegunToolbox) => {
    // retrieve the tools we need
    const {
      parameters,
      template: { generate },
      filesystem,
      print: { error, info, colors },
      strings: { kebabCase },
      system,
      meta,
      prompt,
    } = toolbox

    // set up initial props (to pass into templates)
    const o = parameters.options
    const props = {
      name: parameters.first,
      typescript: Boolean(o.typescript || o.ts || o.t),
      javascript: Boolean(o.javascript || o.js || o.j),
      extension: o.typescript ? 'ts' : 'js',
    }

    // sanity checks
    if (!props.name || props.name.length === 0) {
      error('You must provide a valid CLI name.')
      error('Example: gluegun new movies')
      return undefined
    } else if (!/^[a-z0-9-]+$/.test(props.name)) {
      const validName = kebabCase(props.name)
      error(`${props.name} is not a valid name. Use lower-case and dashes only.`)
      error(`Suggested: gluegun new ${validName}`)
      return undefined
    }

    if (filesystem.exists(props.name)) {
      info(``)
      error(`There's already a folder named ${props.name} here.`)
      const answer = await prompt.confirm(`Do you want to overwrite it?`)
      if (answer) {
        filesystem.remove(props.name)
      } else {
        return undefined
      }
    }

    // typescript or javascript?
    if (!props.typescript && !props.javascript) {
      info(``)
      const { answer } = await prompt.ask({
        type: 'list',
        name: 'answer',
        message: 'Which language would you like to use?',
        choices: [<commit_msg>fix(cli): Change prompt type to fix #462 (#465 by @HunWalk)<commit_after>import { GluegunCommand } from '../../domain/command'
import { GluegunToolbox } from '../../domain/toolbox'

const NewCommand: GluegunCommand = {
  name: 'new',
  alias: ['n', 'create'],
  description: 'Creates a new gluegun cli',
  hidden: false,
  run: async (toolbox: GluegunToolbox) => {
    // retrieve the tools we need
    const {
      parameters,
      template: { generate },
      filesystem,
      print: { error, info, colors },
      strings: { kebabCase },
      system,
      meta,
      prompt,
    } = toolbox

    // set up initial props (to pass into templates)
    const o = parameters.options
    const props = {
      name: parameters.first,
      typescript: Boolean(o.typescript || o.ts || o.t),
      javascript: Boolean(o.javascript || o.js || o.j),
      extension: o.typescript ? 'ts' : 'js',
    }

    // sanity checks
    if (!props.name || props.name.length === 0) {
      error('You must provide a valid CLI name.')
      error('Example: gluegun new movies')
      return undefined
    } else if (!/^[a-z0-9-]+$/.test(props.name)) {
      const validName = kebabCase(props.name)
      error(`${props.name} is not a valid name. Use lower-case and dashes only.`)
      error(`Suggested: gluegun new ${validName}`)
      return undefined
    }

    if (filesystem.exists(props.name)) {
      info(``)
      error(`There's already a folder named ${props.name} here.`)
      const answer = await prompt.confirm(`Do you want to overwrite it?`)
      if (answer) {
        filesystem.remove(props.name)
      } else {
        return undefined
      }
    }

    // typescript or javascript?
    if (!props.typescript && !props.javascript) {
      info(``)
      const { answer } = await prompt.ask({
        type: 'select',
        name: 'answer',
        message: 'Which language would you like to use?',
        choices: [
{'fraction_non_alphanumeric': 0.14105263157894737, 'fraction_numerical': 0.003157894736842105, 'mean_word_length': 2.375666074600355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '626638', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1142, 'n_words': 341}