<commit_before>// @flow

import Command from 'cli-engine-command'
import path from 'path'
import {CustomColors} from 'cli-engine-command/lib/output'

export class AutocompleteBase extends Command {
  get autocompletePath (): string {
    return path.join(this.config.dataDir, 'client', 'node_modules', 'cli-engine', 'autocomplete')
  }

  errorIfWindows () {
    if (this.config.windows) {
      this.out.error('Autocomplete is not currently supported in Windows')
    }
  }
}

export default class Autocomplete extends AutocompleteBase {
  static topic = 'autocomplete'
  static description = 'display autocomplete instructions'
  // hide until beta release
  static hidden = true
  static args = [{name: 'shell', description: 'shell type', required: false}]

  async run () {
    this.errorIfWindows()

    const shell = this.argv[0] || this.config.shell
    if (!shell) {
      this.out.error('Error: Missing required argument shell')
    }

    switch (shell) {
      case 'bash':
        this.out.log('Add the autocomplete function to your .bashrc or .bash_profile via:')
        this.out.log()
        this.out.log(CustomColors.cmd(`$ echo 'source ${path.join(this.autocompletePath, 'bash', 'heroku.bash')}' >> ~/.bashrc`))
        break
      case 'zsh':
        this.out.log('Add the autocomplete function to your fpath via:')
        this.out.log()
        this.out.log(CustomColors.cmd(`$ echo $(heroku autocomplete:script zsh) >> ~/.zshrc`))
        break
      default:
        this.out.error(`Currently ${shell} is not a supported shell for autocomplete`)
    }
    this.out.log()
    this.out.log('Lastly, restart your shell')
  }
}
<commit_msg>Add zsh compaudit help (#222)<commit_after>// @flow

import Command from 'cli-engine-command'
import path from 'path'
import {CustomColors} from 'cli-engine-command/lib/output'

export class AutocompleteBase extends Command {
  get autocompletePath (): string {
    return path.join(this.config.dataDir, 'client', 'node_modules', 'cli-engine', 'autocomplete')
  }

  errorIfWindows () {
    if (this.config.windows) {
      this.out.error('Autocomplete is not currently supported in Windows')
    }
  }
}

export default class Autocomplete extends AutocompleteBase {
  static topic = 'autocomplete'
  static description = 'display autocomplete instructions'
  // hide until beta release
  static hidden = true
  static args = [{name: 'shell', description: 'shell type', required: false}]

  async run () {
    this.errorIfWindows()

    const shell = this.argv[0] || this.config.shell
    if (!shell) {
      this.out.error('Error: Missing required argument shell')
    }

    switch (shell) {
      case 'bash':
        const cmd = CustomColors.cmd(`$ echo 'source ${path.join(this.autocompletePath, 'bash', 'heroku.bash')}' >> ~/.bashrc`)
        this.out.log(`Add the autocomplete function to your .bashrc or .bash_profile via:\n\n${cmd}`)
        break
      case 'zsh':
        const cmd1 = CustomColors.cmd(`$ echo $(heroku autocomplete:script zsh) >> ~/.zshrc`)
        const cmd2 = CustomColors.cmd(`$ compaudit`)
        this.out.log(`Add the autocomplete function to your fpath via:

${cmd1}

Run the following zsh command to ensure no permissions conflicts:

${cmd2}`)
        break
      default:
        this.out.error(`Currently ${shell} is not a supported shell for autocomplete`)
    }
    this.out.log('\nLastly, restart your shell')
  }
}

{'fraction_non_alphanumeric': 0.1290983606557377, 'fraction_numerical': 0.0026346604215456673, 'mean_word_length': 3.281954887218045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '7039598', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1014, 'n_words': 297}