oclif-plugin-completion
Version:
oclif plugin for generating shell completions
35 lines (34 loc) • 1.25 kB
JavaScript
;
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 Completion extends base_1.CompletionBase {
async run() {
const { flags } = this.parse(Completion);
const shell = flags.shell;
const aliases = this.aliases;
const { bin } = this.config;
let instructions = [];
if (shell === 'bash') {
instructions = bash_1.getInstructionsForBash({ bin, shell, aliases });
}
if (shell === 'fish') {
instructions = fish_1.getInstructionsForFish({ bin, shell, aliases });
}
if (shell === 'zsh') {
instructions = zsh_1.getInstructionsForZsh({ bin, shell });
}
this.log(instructions.join('\n'));
}
}
exports.default = Completion;
Completion.description = [
`Generate shell completion script`,
``,
`Run this command to see instructions for your shell.`,
].join('\n');
Completion.args = [];
Completion.flags = Object.assign({}, base_1.CompletionBase.flags);
Completion.examples = ['$ <%= config.bin %> completion --shell zsh'];