mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Format commands plugins help output with indents
This commit is contained in:
parent
569bb6901c
commit
084e6669bc
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user