File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -324,12 +324,6 @@ var usageWantsArgRe = regexp.MustCompile(`<.*>`)
324324// output for a given command.
325325func defaultHelpFn () HandlerFunc {
326326 return func (inv * Invocation ) error {
327- var unknownSubcommandErr error
328- if len (inv .Args ) > 0 {
329- // Detected unknown subcommand.
330- unknownSubcommandErr = fmt .Errorf ("error: unknown subcommand %q" , strings .Join (inv .Args , " " ))
331- _ , _ = fmt .Fprintf (inv .Stderr , "%v\n \n " , unknownSubcommandErr )
332- }
333327 // We use stdout for help and not stderr since there's no straightforward
334328 // way to distinguish between a user error and a help request.
335329 //
@@ -353,7 +347,11 @@ func defaultHelpFn() HandlerFunc {
353347 if len (inv .Args ) > 0 && ! usageWantsArgRe .MatchString (inv .Command .Use ) {
354348 _ , _ = fmt .Fprintf (inv .Stderr , "---\n error: unknown subcommand %q\n " , inv .Args [0 ])
355349 }
356- // Return an error so that exit status is non-zero.
357- return unknownSubcommandErr
350+ if len (inv .Args ) > 0 {
351+ // Return an error so that exit status is non-zero when
352+ // a subcommand is not found.
353+ return fmt .Errorf ("error: unknown subcommand %q" , strings .Join (inv .Args , " " ))
354+ }
355+ return nil
358356 }
359357}
You can’t perform that action at this time.
0 commit comments