Ensure CLI printing of usage info on UsageError doesn't blow up on a help
*function*
This commit is contained in:
parent
5bf78491ff
commit
d4ba912955
@ -334,9 +334,11 @@ function main(argv) {
|
|||||||
// If this is a usage error, attempt to show some usage info.
|
// If this is a usage error, attempt to show some usage info.
|
||||||
if (['Usage', 'Option'].indexOf(code) !== -1 && subcmd) {
|
if (['Usage', 'Option'].indexOf(code) !== -1 && subcmd) {
|
||||||
var help = cli.helpFromSubcmd(subcmd);
|
var help = cli.helpFromSubcmd(subcmd);
|
||||||
if (help) {
|
if (help && typeof (help) === 'string') {
|
||||||
// Would like a shorter synopsis. Attempt to
|
// 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:');
|
var usageIdx = help.indexOf('\nUsage:');
|
||||||
if (usageIdx !== -1) {
|
if (usageIdx !== -1) {
|
||||||
help = help.slice(usageIdx);
|
help = help.slice(usageIdx);
|
||||||
|
Reference in New Issue
Block a user