in lib/cli.js [151:200]
async printUsage(subcommand) {
const cmd = this.commands.get(subcommand);
console.log(bold(`Usage:`));
if (cmd.useArgs === '0-n') {
console.log(` ${this.name} ${subcommand}${cmd.supportAfterCommand ? ' -- <command>' : ''}`);
console.log(` ${this.name} ${subcommand} [arguments]${cmd.supportAfterCommand ? ' -- <command>' : ''}`);
} else if (cmd.useArgs === '1-n') {
console.log(` ${this.name} ${subcommand} [options]${cmd.supportAfterCommand ? ' -- <command>' : ''}`);
} else if (cmd.useArgs === '0') {
console.log(` ${this.name} ${subcommand}${cmd.supportAfterCommand ? ' -- <command>' : ''}`);
}
if (cmd.arguments && cmd.arguments.length > 0) {
let output = ` ${this.name} ${subcommand}`;
for (let i = 0; i < cmd.arguments.length; i++) {
const arg = cmd.arguments[i];
output += ` [${arg.name}]`;
}
console.log(`${output}${cmd.supportAfterCommand ? ' -- <command>' : ''}`);
} else {
console.log(` ${this.name} ${subcommand}${cmd.supportAfterCommand ? ' -- <command>' : ''}`);
}
if (cmd.description) {
console.log();
console.log(bold('Description:'));
console.log(` ${cmd.description}`);
}
if (cmd.options && Object.keys(cmd.options).length > 0) {
console.log();
console.log(bold('Options:'));
Object.keys(cmd.options).forEach((key) => {
const option = cmd.options[key];
console.log(` ${option.short ? `-${option.short}, ` : ''}--${key} [${option.required ? 'Required' : 'Optional'}]`);
console.log(` ${option.description}`);
console.log();
});
}
if (cmd.arguments && cmd.arguments.length > 0) {
console.log();
console.log(bold('Arguments:'));
for (let i = 0; i < cmd.arguments.length; i++) {
const arg = cmd.arguments[i];
console.log(`${arg.name}:`);
console.log(` ${arg.description}`);
}
}
}