Skip to content

Commit

Permalink
fix: only output help and version for non-sub commands
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Oct 6, 2021
1 parent 4247f99 commit 54d5fab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/CAC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ class CAC extends EventEmitter {
this.setParsedInfo(parsed)
}

if (this.options.help && this.showHelpOnExit) {
if (this.options.help && this.showHelpOnExit && this.matchedCommandName == null) {
this.outputHelp()
run = false
this.unsetMatchedCommand()
}

if (this.options.version && this.showVersionOnExit) {
if (this.options.version && this.showVersionOnExit && this.matchedCommandName == null) {
this.outputVersion()
run = false
this.unsetMatchedCommand()
Expand Down

0 comments on commit 54d5fab

Please sign in to comment.