From 084e6669bc7eee995ac33a1080b268bdec45b6da Mon Sep 17 00:00:00 2001 From: Sunny Date: Wed, 21 Jun 2017 00:32:02 +0530 Subject: [PATCH] Format commands plugins help output with indents --- lib/classes/CLI.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/classes/CLI.js b/lib/classes/CLI.js index 687123003..88e22f13f 100644 --- a/lib/classes/CLI.js +++ b/lib/classes/CLI.js @@ -72,18 +72,19 @@ class CLI { return false; } - displayCommandUsage(commandObject, command) { + displayCommandUsage(commandObject, command, indents = 0) { const dotsLength = 30; // check if command has lifecycleEvents (can be executed) if (commandObject.lifecycleEvents) { const usage = commandObject.usage; const dots = _.repeat('.', dotsLength - command.length); - this.consoleLog(`${chalk.yellow(command)} ${chalk.dim(dots)} ${usage}`); + const indent = _.repeat(' ', indents); + this.consoleLog(`${indent}${chalk.yellow(command)} ${chalk.dim(dots)} ${usage}`); } _.forEach(commandObject.commands, (subcommandObject, subcommand) => { - this.displayCommandUsage(subcommandObject, `${command} ${subcommand}`); + this.displayCommandUsage(subcommandObject, `${command} ${subcommand}`, indents); }); } @@ -153,6 +154,14 @@ class CLI { this.consoleLog(''); this.consoleLog(chalk.yellow.underline('Commands by plugin')); + + this.consoleLog(''); + + _.forEach(this.loadedCommands, (details, command) => { + this.consoleLog(details.pluginName); + this.displayCommandUsage(details, command, 1); + this.consoleLog(''); + }); } generateCommandsHelp(commandsArray) {