From 8a500f169b1d18f9f3646bcfcf9641d92d69bd38 Mon Sep 17 00:00:00 2001 From: Mikhail Elhimov Date: Tue, 24 Dec 2024 22:47:42 +0300 Subject: [PATCH] install/uninstall: set program name in proper place --- cli/cmd/install.go | 4 ---- cli/cmd/uninstall.go | 9 +-------- cli/install/install.go | 3 ++- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/cli/cmd/install.go b/cli/cmd/install.go index 3de043c43..e7aaa8917 100644 --- a/cli/cmd/install.go +++ b/cli/cmd/install.go @@ -17,7 +17,6 @@ func newInstallTtCmd() *cobra.Command { Short: "Install tt", Run: func(cmd *cobra.Command, args []string) { cmdCtx.CommandName = cmd.Name() - installCtx.ProgramName = cmd.Name() err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo, internalInstallModule, args) util.HandleCmdErr(cmd, err) @@ -34,7 +33,6 @@ func newInstallTarantoolCmd() *cobra.Command { Short: "Install tarantool community edition", Run: func(cmd *cobra.Command, args []string) { cmdCtx.CommandName = cmd.Name() - installCtx.ProgramName = cmd.Name() err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo, internalInstallModule, args) util.HandleCmdErr(cmd, err) @@ -56,7 +54,6 @@ func newInstallTarantoolEeCmd() *cobra.Command { Short: "Install tarantool enterprise edition", Run: func(cmd *cobra.Command, args []string) { cmdCtx.CommandName = cmd.Name() - installCtx.ProgramName = cmd.Name() err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo, internalInstallModule, args) util.HandleCmdErr(cmd, err) @@ -81,7 +78,6 @@ func newInstallTarantoolDevCmd() *cobra.Command { " tt run # runs the binary compiled above", Run: func(cmd *cobra.Command, args []string) { cmdCtx.CommandName = cmd.Name() - installCtx.ProgramName = cmd.Name() err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo, internalInstallModule, args) util.HandleCmdErr(cmd, err) diff --git a/cli/cmd/uninstall.go b/cli/cmd/uninstall.go index 219d2dd35..ccf67c963 100644 --- a/cli/cmd/uninstall.go +++ b/cli/cmd/uninstall.go @@ -10,10 +10,6 @@ import ( "github.com/tarantool/tt/cli/util" ) -var ( - programName string -) - // newUninstallTtCmd creates a command to install tt. func newUninstallTtCmd() *cobra.Command { var tntCmd = &cobra.Command{ @@ -21,7 +17,6 @@ func newUninstallTtCmd() *cobra.Command { Short: "Uninstall tt", Run: func(cmd *cobra.Command, args []string) { cmdCtx.CommandName = cmd.Name() - programName = cmd.Name() err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo, InternalUninstallModule, args) util.HandleCmdErr(cmd, err) @@ -48,7 +43,6 @@ func newUninstallTarantoolCmd() *cobra.Command { Short: "Uninstall tarantool community edition", Run: func(cmd *cobra.Command, args []string) { cmdCtx.CommandName = cmd.Name() - programName = cmd.Name() err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo, InternalUninstallModule, args) util.HandleCmdErr(cmd, err) @@ -75,7 +69,6 @@ func newUninstallTarantoolEeCmd() *cobra.Command { Short: "Uninstall tarantool enterprise edition", Run: func(cmd *cobra.Command, args []string) { cmdCtx.CommandName = cmd.Name() - programName = cmd.Name() err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo, InternalUninstallModule, args) util.HandleCmdErr(cmd, err) @@ -102,7 +95,6 @@ func newUninstallTarantoolDevCmd() *cobra.Command { Short: "Uninstall tarantool-dev", Run: func(cmd *cobra.Command, args []string) { cmdCtx.CommandName = cmd.Name() - programName = cmd.Name() err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo, InternalUninstallModule, args) util.HandleCmdErr(cmd, err) @@ -139,6 +131,7 @@ func InternalUninstallModule(cmdCtx *cmdcontext.CmdCtx, args []string) error { return errNoConfig } + programName := cmdCtx.CommandName programVersion := "" if len(args) == 1 { programVersion = args[0] diff --git a/cli/install/install.go b/cli/install/install.go index 563f3e30e..7cd504ab8 100644 --- a/cli/install/install.go +++ b/cli/install/install.go @@ -1591,10 +1591,11 @@ func Install(binDir string, includeDir string, installCtx InstallCtx, } func FillCtx(cmdCtx *cmdcontext.CmdCtx, installCtx *InstallCtx, args []string) error { + installCtx.ProgramName = cmdCtx.CommandName installCtx.verbose = cmdCtx.Cli.Verbose installCtx.skipMasterUpdate = cmdCtx.Cli.NoPrompt - if cmdCtx.CommandName == search.ProgramDev { + if installCtx.ProgramName == search.ProgramDev { if len(args) != 1 { return fmt.Errorf("exactly one build directory must be specified") }