Ensure CLI printing of usage info on UsageError doesn't blow up on a help *function*

This commit is contained in:
Trent Mick 2015-11-03 14:39:37 -08:00
parent 5bf78491ff
commit d4ba912955

View File

@ -334,9 +334,11 @@ function main(argv) {
// If this is a usage error, attempt to show some usage info.
if (['Usage', 'Option'].indexOf(code) !== -1 && subcmd) {
var help = cli.helpFromSubcmd(subcmd);
if (help) {
if (help && typeof (help) === 'string') {
// Would like a shorter synopsis. Attempt to
// parse it down, somewhat generally.
// parse it down, somewhat generally. Unfortunately this
// doesn't work for multi-level subcmds, like
// `triton rbac subcmd ...`.
var usageIdx = help.indexOf('\nUsage:');
if (usageIdx !== -1) {
help = help.slice(usageIdx);