Skip to content

Commit 54d5fab

Browse files
committedOct 6, 2021
fix: only output help and version for non-sub commands
1 parent 4247f99 commit 54d5fab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎src/CAC.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,13 @@ class CAC extends EventEmitter {
214214
this.setParsedInfo(parsed)
215215
}
216216

217-
if (this.options.help && this.showHelpOnExit) {
217+
if (this.options.help && this.showHelpOnExit && this.matchedCommandName == null) {
218218
this.outputHelp()
219219
run = false
220220
this.unsetMatchedCommand()
221221
}
222222

223-
if (this.options.version && this.showVersionOnExit) {
223+
if (this.options.version && this.showVersionOnExit && this.matchedCommandName == null) {
224224
this.outputVersion()
225225
run = false
226226
this.unsetMatchedCommand()

0 commit comments

Comments
 (0)
Please sign in to comment.