cli-engine
Version:
Generic CLI Framework
75 lines (58 loc) • 2.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AutocompleteBase = undefined;
var _cliEngineCommand = require('cli-engine-command');
var _cliEngineCommand2 = _interopRequireDefault(_cliEngineCommand);
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _output = require('cli-engine-command/lib/output');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class AutocompleteBase extends _cliEngineCommand2.default {
get functionsPath() {
return _path2.default.join(__dirname, '..', '..', '..', 'autocomplete');
}
get completionsPath() {
return _path2.default.join(this.config.cacheDir, 'completions');
}
errorIfWindows() {
if (this.config.windows) {
this.out.error('Autocomplete is not currently supported in Windows');
}
}
}
exports.AutocompleteBase = AutocompleteBase;
class Autocomplete extends AutocompleteBase {
// hide until beta release
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 = _output.CustomColors.cmd(`$ echo $(heroku autocomplete:script bash) >> ~/.bashrc`);
this.out.log(`Add the autocomplete setup script to your .bashrc or .bash_profile via:
${cmd}`);
break;
case 'zsh':
const cmd1 = _output.CustomColors.cmd(`$ echo $(heroku autocomplete:script zsh) >> ~/.zshrc`);
const cmd2 = _output.CustomColors.cmd(`$ compaudit`);
this.out.log(`Add the autocomplete setup script to your .zshrc 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');
}
}
exports.default = Autocomplete;
Autocomplete.topic = 'autocomplete';
Autocomplete.description = 'display autocomplete instructions';
Autocomplete.hidden = true;
Autocomplete.args = [{ name: 'shell', description: 'shell type', required: false }];