Skip to content

Commit

Permalink
Add support for edge case when help is disabled but a --help flag is …
Browse files Browse the repository at this point in the history
…still provided (Was treated like an unknown command instead of a flag)
  • Loading branch information
coreybutler committed Apr 30, 2020
1 parent 51fb2ce commit 194b86d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
2 changes: 1 addition & 1 deletion test/unit/01-sanity/01-sanity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 194b86d

Please sign in to comment.