Skip to content

Commit b77c204

Browse files
committed
external: configure external cmd similar to the other commands
Part of #1136
1 parent 7e6f40f commit b77c204

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

cli/cmd/external.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cmd
33
import (
44
"strings"
55

6-
"github.com/apex/log"
76
"github.com/spf13/cobra"
87
"github.com/tarantool/tt/cli/modules"
98
)
@@ -50,8 +49,7 @@ func configureNonExistentCmd(rootCmd *cobra.Command,
5049

5150
externalCmdPath := rootCmd.Name() + " " + externalCmd
5251
if _, found := (*modulesInfo)[externalCmdPath]; found {
53-
rootCmd.AddCommand(newExternalCommand(modulesInfo, externalCmd,
54-
externalCmdPath))
52+
rootCmd.AddCommand(newExternalCmd(externalCmd))
5553
}
5654
}
5755

@@ -65,20 +63,14 @@ func externalCmdHelpFunc(cmd *cobra.Command, args []string) {
6563
cmd.Print(helpMsg)
6664
}
6765

68-
// newExternalCommand returns a pointer to a new external
66+
// newExternalCmd returns a pointer to a new external
6967
// command that will call modules.RunCmd.
70-
func newExternalCommand(modulesInfo *modules.ModulesInfo,
71-
cmdName, cmdPath string) *cobra.Command {
72-
cmd := &cobra.Command{
73-
Use: cmdName,
74-
Run: func(cmd *cobra.Command, args []string) {
75-
cmdCtx.Cli.ForceInternal = false
76-
if err := modules.RunCmd(&cmdCtx, cmdPath, modulesInfo, nil, args); err != nil {
77-
log.Fatalf(err.Error())
78-
}
79-
},
68+
func newExternalCmd(cmdName string) *cobra.Command {
69+
var cmd = &cobra.Command{
70+
Use: cmdName,
71+
Run: RunModuleFunc(nil),
72+
DisableFlagParsing: true,
8073
}
81-
cmd.DisableFlagParsing = true
8274
cmd.SetHelpFunc(externalCmdHelpFunc)
8375
return cmd
8476
}

0 commit comments

Comments
 (0)