in lib/cli.js [90:122]
async completion(args) {
if (args.length === 0) {
for (const [name] of this.commands) {
console.log(name);
}
return;
}
if (args.length === 1) {
const prefix = args[0];
for (const [name] of this.commands) {
if (name.startsWith(prefix)) {
console.log(name);
}
}
return;
}
// after --, no more auto completion
if (args.indexOf('--') !== -1) {
return;
}
// eslint-disable-next-line no-unused-vars
const [name, ...others] = args;
const cmd = this.commands.get(name);
if (cmd.options) {
Object.keys(cmd.options).forEach((item) => {
console.log(`--${item}`);
});
return;
}
}