File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,11 @@ import (
88 "github.com/spf13/cobra"
99)
1010
11- func rootDisplayCommandTypoHelp (command * cobra.Command , args []string ) {
11+ func rootHelpFunc (command * cobra.Command , args []string ) {
12+ // Display helpful error message in case subcommand name was mistyped.
13+ // This matches Cobra's behavior for root command, which Cobra
14+ // confusingly doesn't apply to nested commands.
1215 if command != RootCmd {
13- // Display helpful error message in case subcommand name was mistyped.
14- // This matches Cobra's behavior for root command, which Cobra
15- // confusingly doesn't apply to nested commands.
1616 if command .Parent () == RootCmd && len (args ) >= 2 {
1717 if command .SuggestionsMinimumDistance <= 0 {
1818 command .SuggestionsMinimumDistance = 2
@@ -32,13 +32,9 @@ func rootDisplayCommandTypoHelp(command *cobra.Command, args []string) {
3232
3333 oldOut := command .OutOrStdout ()
3434 command .SetOut (errOut )
35- command .SetOut (oldOut )
35+ defer command .SetOut (oldOut )
3636 }
3737 }
38- }
39-
40- func rootHelpFunc (command * cobra.Command , args []string ) {
41- rootDisplayCommandTypoHelp (command , args )
4238
4339 coreCommands := []string {}
4440 additionalCommands := []string {}
You can’t perform that action at this time.
0 commit comments