Skip to content

Commit 2fb48e9

Browse files
committed
Inline method call
1 parent 7d7a010 commit 2fb48e9

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

command/help.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff 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{}

0 commit comments

Comments
 (0)