From 194b86d6462292010b37eb29ddd1ed7e02528cd5 Mon Sep 17 00:00:00 2001 From: Corey Butler Date: Wed, 29 Apr 2020 22:23:23 -0500 Subject: [PATCH] Add support for edge case when help is disabled but a --help flag is still provided (Was treated like an unknown command instead of a flag) --- src/shell.js | 8 +++++++- test/unit/01-sanity/01-sanity.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/shell.js b/src/shell.js index 3a0669b..3d4f925 100644 --- a/src/shell.js +++ b/src/shell.js @@ -164,7 +164,13 @@ export default class Shell extends Base { } }, []) - if (this.middleware.size === 0) { + if (args.trim().toLowerCase() === '--help') { + if (!this.autohelp) { + return await Command.reply() + } + } + + if (this.middleware.size === 0) { return await Command.reply(await processor.run(args, callback)) } diff --git a/test/unit/01-sanity/01-sanity.js b/test/unit/01-sanity/01-sanity.js index ba5356e..9f53242 100644 --- a/test/unit/01-sanity/01-sanity.js +++ b/test/unit/01-sanity/01-sanity.js @@ -195,7 +195,7 @@ test('Default command help (regression test)', t => { ] }) - shell.exec('account create --help') + shell.exec('account') // console.log('---------') // shell.exec('blah') t.pass('ok')