UNPKG

oclif-plugin-completion

Version:
47 lines (46 loc) 1.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const base_1 = require("../../../base"); const bash_1 = require("../../../utils/bash"); const fish_1 = require("../../../utils/fish"); const zsh_1 = require("../../../utils/zsh"); class CompletionGenerate extends base_1.CompletionBase { async run() { const { flags } = this.parse(CompletionGenerate); const shell = flags.shell; const aliases = this.aliases; const { bin, commands } = this.config; let scriptContent = ''; if (shell === 'bash') { scriptContent = bash_1.generateCompletionScriptForBash({ bin, aliases, commands, }); } if (shell === 'fish') { scriptContent = fish_1.generateCompletionScriptForFish({ bin, aliases, commands, }); } if (shell === 'zsh') { scriptContent = zsh_1.generateCompletionScriptForZsh({ bin, aliases, commands, }); } this.log(scriptContent); } } exports.default = CompletionGenerate; CompletionGenerate.description = [ `Generates completion script`, ``, `Run the "completion" command to see instructions about how to use the script generated by this command.`, ].join('\n'); CompletionGenerate.args = []; CompletionGenerate.flags = Object.assign({}, base_1.CompletionBase.flags); CompletionGenerate.examples = ['$ <%= config.bin %> completion:generate --shell zsh'];