File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -322,6 +322,14 @@ func (lm *newlineLimiter) Write(p []byte) (int, error) {
322322
323323var usageWantsArgRe = regexp .MustCompile (`<.*>` )
324324
325+ type UnknownSubcommandError struct {
326+ Args []string
327+ }
328+
329+ func (e * UnknownSubcommandError ) Error () string {
330+ return fmt .Sprintf ("unknown subcommand %q" , strings .Join (e .Args , " " ))
331+ }
332+
325333// DefaultHelpFn returns a function that generates usage (help)
326334// output for a given command.
327335func DefaultHelpFn () HandlerFunc {
@@ -352,7 +360,7 @@ func DefaultHelpFn() HandlerFunc {
352360if len (inv .Args ) > 0 {
353361// Return an error so that exit status is non-zero when
354362// a subcommand is not found.
355- return fmt . Errorf ( "error: unknown subcommand %q" , strings . Join ( inv .Args , " " ))
363+ return & UnknownSubcommandError { Args : inv .Args }
356364}
357365return nil
358366}
You can’t perform that action at this time.
0 commit comments