Skip to content

Commit

Permalink
Print out help instead of returning it
Browse files Browse the repository at this point in the history
  • Loading branch information
Yord committed Jun 24, 2020
1 parent 063e364 commit f965228
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/commands/shargs/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,20 @@ function call(commands, broker, command) {
cols: [{ width: 25, padEnd: 2 }, { width: 53 }],
};

let help = ''

if (Array.isArray(command) && command.length === 0) {
return optsLists(commands)(style);
help = optsLists(commands)(style);
} else {
const command2 = Array.isArray(command) ? command : [command];
const subcommands = commands.opts.filter(({ key }) =>
command2.includes(key)
);
const helps = subcommands.map((cmd) => subDocs(cmd)(style));
help = helps.join("\n");
}

const command2 = Array.isArray(command) ? command : [command];
const subcommands = commands.opts.filter(({ key }) =>
command2.includes(key)
);
const helps = subcommands.map((cmd) => subDocs(cmd)(style));
return helps.join("\n");
console.log(help)
}

module.exports = function (commands, broker) {
Expand Down

0 comments on commit f965228

Please sign in to comment.