Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor uninstall #1089

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove code duplication in Command.Run functions
Closes #1072
  • Loading branch information
elhimov committed Mar 18, 2025
commit 7a7758baa4a89332d90a93231d1bbe82091ca8a1
8 changes: 1 addition & 7 deletions cli/cmd/aeon.go
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ import (
aeoncmd "github.com/tarantool/tt/cli/aeon/cmd"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/console"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/util"
"github.com/tarantool/tt/lib/cluster"
@@ -37,12 +36,7 @@ func newAeonConnectCmd() *cobra.Command {
tt aeon connect http://localhost:50051
tt aeon connect unix://<socket-path>
tt aeon connect /path/to/config INSTANCE_NAME>`,
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalAeonConnect, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalAeonConnect),
Args: cobra.MatchAll(cobra.RangeArgs(1, 2), aeonConnectValidateArgs),
}

14 changes: 2 additions & 12 deletions cli/cmd/binaries.go
Original file line number Diff line number Diff line change
@@ -6,9 +6,7 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/binary"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/search"
"github.com/tarantool/tt/cli/util"
"golang.org/x/exp/slices"
)

@@ -43,21 +41,13 @@ You will need to choose version using arrow keys in your console.
# Switch with program and version.

$ tt binaries switch tarantool 2.10.4`,
Run: func(cmd *cobra.Command, args []string) {
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalSwitchModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalSwitchModule),
Args: cobra.MatchAll(cobra.MaximumNArgs(2), binariesSwitchValidateArgs),
}
var listCmd = &cobra.Command{
Use: "list",
Short: "Show a list of installed binaries and their versions.",
Run: func(cmd *cobra.Command, args []string) {
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalListModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalListModule),
}
binariesCmd.AddCommand(switchCmd)
binariesCmd.AddCommand(listCmd)
10 changes: 2 additions & 8 deletions cli/cmd/build.go
Original file line number Diff line number Diff line change
@@ -4,9 +4,7 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/build"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/util"
)

var (
@@ -19,12 +17,8 @@ func NewBuildCmd() *cobra.Command {
var buildCmd = &cobra.Command{
Use: "build [<PATH> | <APP_NAME>] [flags]",
Short: `Build an application (default ".")`,
Run: func(cmd *cobra.Command, args []string) {
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalBuildModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.MaximumNArgs(1),
Run: TtModuleCmdRun(internalBuildModule),
Args: cobra.MaximumNArgs(1),
ValidArgsFunction: func(
cmd *cobra.Command,
args []string,
8 changes: 1 addition & 7 deletions cli/cmd/cat.go
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/checkpoint"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/util"
"github.com/tarantool/tt/cli/version"
)
@@ -34,12 +33,7 @@ func NewCatCmd() *cobra.Command {
var catCmd = &cobra.Command{
Use: "cat <FILE>...",
Short: "Print into stdout the contents of .snap/.xlog FILE(s)",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalCatModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalCatModule),
Example: "tt cat /path/to/file.snap /path/to/file.xlog /path/to/dir/ " +
"--timestamp 2024-11-13T14:02:36.818700000+00:00\n" +
" tt cat /path/to/file.snap /path/to/file.xlog /path/to/dir/ " +
9 changes: 1 addition & 8 deletions cli/cmd/cfg_dump.go
Original file line number Diff line number Diff line change
@@ -6,8 +6,6 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cfg"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/util"
)

var (
@@ -19,12 +17,7 @@ func NewDumpCmd() *cobra.Command {
var dumpCmd = &cobra.Command{
Use: "dump",
Short: "Print environment configuration",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalDumpModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalDumpModule),
}

dumpCmd.Flags().BoolVarP(&rawDump, "raw", "r", false,
9 changes: 1 addition & 8 deletions cli/cmd/check.go
Original file line number Diff line number Diff line change
@@ -4,22 +4,15 @@ import (
"github.com/apex/log"
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/util"
)

// NewCheckCmd creates a new check command.
func NewCheckCmd() *cobra.Command {
var checkCmd = &cobra.Command{
Use: "check [<APPLICATION_NAME>]",
Short: "Check an application file for syntax errors",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalCheckModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalCheckModule),
}

return checkCmd
9 changes: 2 additions & 7 deletions cli/cmd/clean.go
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmd/internal"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/process_utils"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/util"
@@ -23,11 +22,7 @@ func NewCleanCmd() *cobra.Command {
var cleanCmd = &cobra.Command{
Use: "clean [INSTANCE_NAME]",
Short: "Clean instance(s) files",
Run: func(cmd *cobra.Command, args []string) {
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo, internalCleanModule,
args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalCleanModule),
ValidArgsFunction: func(
cmd *cobra.Command,
args []string,
@@ -83,7 +78,7 @@ func clean(run *running.InstanceCtx) error {
}

if confirm || forceRemove {
for file, _ := range removeFiles {
for file := range removeFiles {
err = os.Remove(file)
if err != nil {
return err
74 changes: 14 additions & 60 deletions cli/cmd/cluster.go
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ import (
clustercmd "github.com/tarantool/tt/cli/cluster/cmd"
"github.com/tarantool/tt/cli/cmd/internal"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/replicaset"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/util"
@@ -146,13 +145,8 @@ func newClusterReplicasetCmd() *cobra.Command {
DisableFlagsInUseLine: true,
Short: "Promote an instance",
Long: "Promote an instance\n\n" + clusterUriHelp,
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalClusterReplicasetPromoteModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(2),
Run: TtModuleCmdRun(internalClusterReplicasetPromoteModule),
Args: cobra.ExactArgs(2),
}
promoteCmd.Flags().StringVarP(&promoteCtx.Username, "username", "u", "",
"username (used as etcd/tarantool config storage credentials)")
@@ -167,13 +161,8 @@ func newClusterReplicasetCmd() *cobra.Command {
DisableFlagsInUseLine: true,
Short: "Demote an instance",
Long: "Demote an instance\n\n" + clusterUriHelp,
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalClusterReplicasetDemoteModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(2),
Run: TtModuleCmdRun(internalClusterReplicasetDemoteModule),
Args: cobra.ExactArgs(2),
}

demoteCmd.Flags().StringVarP(&demoteCtx.Username, "username", "u", "",
@@ -189,13 +178,8 @@ func newClusterReplicasetCmd() *cobra.Command {
DisableFlagsInUseLine: true,
Short: "Expel an instance",
Long: "Expel an instance\n\n" + clusterUriHelp,
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalClusterReplicasetExpelModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(2),
Run: TtModuleCmdRun(internalClusterReplicasetExpelModule),
Args: cobra.ExactArgs(2),
}

expelCmd.Flags().StringVarP(&expelCtx.Username, "username", "u", "",
@@ -215,12 +199,7 @@ func newClusterReplicasetCmd() *cobra.Command {
Use: "add <URI> <ROLE_NAME> [flags]",
Short: "Add role to an instance, group or instance",
Long: "Add role to an instance, group or instance\n\n" + clusterUriHelp,
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalClusterReplicasetRolesAddModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalClusterReplicasetRolesAddModule),
Example: "tt cluster replicaset roles add http://user:pass@localhost:3301" +
" roles.metrics-export --instance_name master",
Args: cobra.ExactArgs(2),
@@ -247,12 +226,7 @@ func newClusterReplicasetCmd() *cobra.Command {
Use: "remove <URI> <ROLE_NAME> [flags]",
Short: "Remove role from instance, group, instance or globally",
Long: "Remove role from instance, group, instance or globally\n\n" + clusterUriHelp,
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalClusterReplicasetRolesRemoveModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalClusterReplicasetRolesRemoveModule),
Example: "tt cluster replicaset roles remove http://user:pass@localhost:3301" +
" roles.metrics-export --instance_name master",
Args: cobra.ExactArgs(2),
@@ -299,13 +273,8 @@ func newClusterFailoverCmd() *cobra.Command {
Short: "Switch master instance",
Long: "Switch master instance\n\n" + failoverUriHelp,
Example: "tt cluster failover switch http://localhost:2379/app instance_name",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalClusterFailoverSwitchModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(2),
Run: TtModuleCmdRun(internalClusterFailoverSwitchModule),
Args: cobra.ExactArgs(2),
}

switchCmd.Flags().StringVarP(&switchCtx.Username, "username", "u", "",
@@ -322,13 +291,8 @@ func newClusterFailoverCmd() *cobra.Command {
DisableFlagsInUseLine: true,
Short: "Show master switching status",
Long: "Show master switching status\n\n" + failoverUriHelp,
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalClusterFailoverSwitchStatusModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(2),
Run: TtModuleCmdRun(internalClusterFailoverSwitchStatusModule),
Args: cobra.ExactArgs(2),
}

cmd.AddCommand(switchCmd)
@@ -352,12 +316,7 @@ func NewClusterCmd() *cobra.Command {
" tt cluster show application_name:instance_name\n" +
" tt cluster show https://user:pass@localhost:2379/tt\n" +
" tt cluster show https://user:pass@localhost:2379/tt?name=instance",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalClusterShowModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalClusterShowModule),
Args: cobra.ExactArgs(1),
ValidArgsFunction: func(
cmd *cobra.Command,
@@ -399,12 +358,7 @@ func NewClusterCmd() *cobra.Command {
" tt cluster publish --group group --replicaset replicaset " +
"https://user:pass@localhost:2379/tt?name=instance " +
"instance.yaml",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalClusterPublishModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalClusterPublishModule),
Args: cobra.ExactArgs(2),
ValidArgsFunction: func(
cmd *cobra.Command,
13 changes: 13 additions & 0 deletions cli/cmd/common.go
Original file line number Diff line number Diff line change
@@ -5,8 +5,11 @@ import (
"fmt"
"io"

"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/configure"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/util"
libcluster "github.com/tarantool/tt/lib/cluster"
"github.com/tarantool/tt/lib/integrity"
)
@@ -67,3 +70,13 @@ func createDataCollectorsAndDataPublishers(ctx integrity.IntegrityCtx,
}
return collectors, publishers, err
}

func TtModuleCmdRun(internalModule modules.InternalFunc) func(*cobra.Command, []string) {
return func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo, internalModule, args)
if err != nil {
util.HandleCmdErr(cmd, err)
}
}
}
10 changes: 2 additions & 8 deletions cli/cmd/completion.go
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ import (
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/rocks"
"github.com/tarantool/tt/cli/util"
)

// NewCompletionCmd creates a new completion command.
@@ -18,13 +17,8 @@ func NewCompletionCmd() *cobra.Command {
Use: "completion <SHELL_TYPE>",
Short: "Generate autocomplete for a specified shell. Supported shell type: bash | zsh",
ValidArgs: []string{"bash", "zsh"},
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalCompletionCmd, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
Run: TtModuleCmdRun(internalCompletionCmd),
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
Example: `
# Enable auto-completion in current bash shell.

8 changes: 1 addition & 7 deletions cli/cmd/connect.go
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ import (
"github.com/tarantool/tt/cli/connect"
"github.com/tarantool/tt/cli/connector"
"github.com/tarantool/tt/cli/formatter"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/util"
libconnect "github.com/tarantool/tt/lib/connect"
@@ -61,12 +60,7 @@ func NewConnectCmd() *cobra.Command {
"You could pass command line arguments to the interpreted SCRIPT" +
" or COMMAND passed via -f flag:\n\n" +
`echo "print(...)" | tt connect user:pass@localhost:3013 -f- 1, 2, 3`,
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalConnectModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalConnectModule),
Args: cobra.MinimumNArgs(1),
ValidArgsFunction: func(
cmd *cobra.Command,
37 changes: 16 additions & 21 deletions cli/cmd/coredump.go
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/coredump"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/util"
)

var (
@@ -26,13 +24,8 @@ func NewCoredumpCmd() *cobra.Command {
var packCmd = &cobra.Command{
Use: "pack COREDUMP",
Short: "pack tarantool coredump into tar.gz archive",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalCoredumpPackModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(1),
Run: TtModuleCmdRun(internalCoredumpPackModule),
Args: cobra.ExactArgs(1),
}
packCmd.Flags().StringVarP(&coredumpPackExecutable, "executable", "e", "",
"Tarantool executable path")
@@ -48,23 +41,15 @@ func NewCoredumpCmd() *cobra.Command {
var unpackCmd = &cobra.Command{
Use: "unpack ARCHIVE",
Short: "unpack tarantool coredump tar.gz archive",
Run: func(cmd *cobra.Command, args []string) {
if err := coredump.Unpack(args[0]); err != nil {
util.HandleCmdErr(cmd, err)
}
},
Args: cobra.ExactArgs(1),
Run: TtModuleCmdRun(internalCoredumpUnpackModule),
Args: cobra.ExactArgs(1),
}

var inspectCmd = &cobra.Command{
Use: "inspect {ARCHIVE|DIRECTORY}",
Short: "inspect tarantool coredump",
Run: func(cmd *cobra.Command, args []string) {
if err := coredump.Inspect(args[0], coredumpInspectSourceDir); err != nil {
util.HandleCmdErr(cmd, err)
}
},
Args: cobra.ExactArgs(1),
Run: TtModuleCmdRun(internalCoredumpInspectModule),
Args: cobra.ExactArgs(1),
}
inspectCmd.Flags().StringVarP(&coredumpInspectSourceDir, "sourcedir", "s", "",
"Source directory")
@@ -91,3 +76,13 @@ func internalCoredumpPackModule(cmdCtx *cmdcontext.CmdCtx, args []string) error
coredumpPackTime,
)
}

// internalCoredumpUnpackModule is a default "unpack" command for the coredump module.
func internalCoredumpUnpackModule(cmdCtx *cmdcontext.CmdCtx, args []string) error {
return coredump.Unpack(args[0])
}

// internalCoredumpInspectModule is a default "inspect" command for the coredump module.
func internalCoredumpInspectModule(cmdCtx *cmdcontext.CmdCtx, args []string) error {
return coredump.Inspect(args[0], coredumpInspectSourceDir)
}
7 changes: 1 addition & 6 deletions cli/cmd/create.go
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ import (
"github.com/tarantool/tt/cli/create"
"github.com/tarantool/tt/cli/create/builtin_templates"
create_ctx "github.com/tarantool/tt/cli/create/context"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/util"
)

@@ -32,11 +31,7 @@ func NewCreateCmd() *cobra.Command {
var createCmd = &cobra.Command{
Use: "create <TEMPLATE_NAME> [flags]",
Short: "Create an application from a template",
Run: func(cmd *cobra.Command, args []string) {
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalCreateModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalCreateModule),
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("requires template name argument")
34 changes: 8 additions & 26 deletions cli/cmd/daemon.go
Original file line number Diff line number Diff line change
@@ -6,9 +6,7 @@ import (
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/configure"
"github.com/tarantool/tt/cli/daemon"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/process_utils"
"github.com/tarantool/tt/cli/util"
)

// NewDaemonCmd creates daemon command.
@@ -21,45 +19,29 @@ func NewDaemonCmd() *cobra.Command {
var startCmd = &cobra.Command{
Use: "start",
Short: "start tt daemon",
Run: func(cmd *cobra.Command, args []string) {
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalDaemonStartModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(0),
Run: TtModuleCmdRun(internalDaemonStartModule),
Args: cobra.ExactArgs(0),
}

var stopCmd = &cobra.Command{
Use: "stop",
Short: "stop tt daemon",
Run: func(cmd *cobra.Command, args []string) {
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalDaemonStopModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(0),
Run: TtModuleCmdRun(internalDaemonStopModule),
Args: cobra.ExactArgs(0),
}

var statusCmd = &cobra.Command{
Use: "status",
Short: "status of tt daemon",
Run: func(cmd *cobra.Command, args []string) {
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalDaemonStatusModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(0),
Run: TtModuleCmdRun(internalDaemonStatusModule),
Args: cobra.ExactArgs(0),
}

var restartCmd = &cobra.Command{
Use: "restart",
Short: "restart tt daemon",
Run: func(cmd *cobra.Command, args []string) {
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalDaemonRestartModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(0),
Run: TtModuleCmdRun(internalDaemonRestartModule),
Args: cobra.ExactArgs(0),
}

daemonSubCommands := []*cobra.Command{
9 changes: 1 addition & 8 deletions cli/cmd/download.go
Original file line number Diff line number Diff line change
@@ -6,8 +6,6 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/download"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/util"
)

var (
@@ -24,12 +22,7 @@ func NewDownloadCmd() *cobra.Command {
$ tt download gc64-3.0.0-0-gf58f7d82a-r23
# Download Tarantool SDK development build to the /tmp directory.
$ tt download gc64-3.0.0-beta1-2-gcbb569b4c-r612 --dev --directory-prefix /tmp`,
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalDownloadModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalDownloadModule),
Args: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("to download Tarantool SDK, you need to specify the version")
8 changes: 1 addition & 7 deletions cli/cmd/enable.go
Original file line number Diff line number Diff line change
@@ -7,8 +7,6 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/enable"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/util"
)

// NewEnableCmd creates a new enable command.
@@ -22,11 +20,7 @@ func NewEnableCmd() *cobra.Command {
$ tt enable Users/myuser/my_scripts/script.lua
# Create a symbolic link in 'instances_enabled' directory to an application directory.
$ tt enable ../myuser/my_cool_app`,
Run: func(cmd *cobra.Command, args []string) {
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalEnableModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalEnableModule),
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return errors.New("provide the path to a script or application directory")
8 changes: 1 addition & 7 deletions cli/cmd/env.go
Original file line number Diff line number Diff line change
@@ -6,8 +6,6 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/env"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/util"
)

// NewEnvCmd creates env command.
@@ -17,11 +15,7 @@ func NewEnvCmd() *cobra.Command {
Short: "Add current environment binaries location to the PATH variable",
Long: "Add current environment binaries location to the PATH variable.\n" +
"Also sets TARANTOOL_DIR variable.",
Run: func(cmd *cobra.Command, args []string) {
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalEnvModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalEnvModule),
}

return envCmd
8 changes: 1 addition & 7 deletions cli/cmd/init.go
Original file line number Diff line number Diff line change
@@ -7,8 +7,6 @@ import (
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/configure"
init_pkg "github.com/tarantool/tt/cli/init"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/util"
)

var initCtx init_pkg.InitCtx
@@ -20,11 +18,7 @@ func NewInitCmd() *cobra.Command {
var initCmd = &cobra.Command{
Use: "init [flags]",
Short: "Create tt environment config for application in current directory",
Run: func(cmd *cobra.Command, args []string) {
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalInitModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalInitModule),
}

initCmd.Flags().BoolVarP(&initCtx.SkipConfig, "skip-config", "", false,
36 changes: 7 additions & 29 deletions cli/cmd/install.go
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/install"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/util"
)

var installCtx install.InstallCtx
@@ -15,13 +13,8 @@ func newInstallTtCmd() *cobra.Command {
var tntCmd = &cobra.Command{
Use: "tt [version|commit hash|pull-request]",
Short: "Install tt",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalInstallModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.MaximumNArgs(1),
Run: TtModuleCmdRun(internalInstallModule),
Args: cobra.MaximumNArgs(1),
}

return tntCmd
@@ -32,13 +25,8 @@ func newInstallTarantoolCmd() *cobra.Command {
var tntCmd = &cobra.Command{
Use: "tarantool [version|commit hash|pull-request]",
Short: "Install tarantool community edition",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalInstallModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.MaximumNArgs(1),
Run: TtModuleCmdRun(internalInstallModule),
Args: cobra.MaximumNArgs(1),
}

tntCmd.Flags().BoolVarP(&installCtx.BuildInDocker, "use-docker", "", false,
@@ -54,13 +42,8 @@ func newInstallTarantoolEeCmd() *cobra.Command {
var tntCmd = &cobra.Command{
Use: "tarantool-ee [version]",
Short: "Install tarantool enterprise edition",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalInstallModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.MaximumNArgs(1),
Run: TtModuleCmdRun(internalInstallModule),
Args: cobra.MaximumNArgs(1),
}

tntCmd.Flags().BoolVar(&installCtx.DevBuild, "dev", false, "install development build")
@@ -79,12 +62,7 @@ func newInstallTarantoolDevCmd() *cobra.Command {
" make -j16 -C ~/src/tarantool/build\n" +
" tt install tarantool-dev ~/src/tarantool/build\n" +
" tt run # runs the binary compiled above",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalInstallModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalInstallModule),
Args: cobra.ExactArgs(1),
}

11 changes: 2 additions & 9 deletions cli/cmd/instances.go
Original file line number Diff line number Diff line change
@@ -4,22 +4,15 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/instances"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/util"
)

// NewInstancesCmd creates instances command.
func NewInstancesCmd() *cobra.Command {
var instancesCmd = &cobra.Command{
Use: "instances",
Short: "Show list of enabled applications",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalInstancesModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(0),
Run: TtModuleCmdRun(internalInstancesModule),
Args: cobra.ExactArgs(0),
}

return instancesCmd
8 changes: 1 addition & 7 deletions cli/cmd/kill.go
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmd/internal"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/util"
)
@@ -22,12 +21,7 @@ func NewKillCmd() *cobra.Command {
var killCmd = &cobra.Command{
Use: "kill [<APP_NAME> | <APP_NAME:INSTANCE_NAME>]",
Short: "Kill tarantool instance(s)",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalKillModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalKillModule),
ValidArgsFunction: func(
cmd *cobra.Command,
args []string,
9 changes: 1 addition & 8 deletions cli/cmd/log.go
Original file line number Diff line number Diff line change
@@ -11,10 +11,8 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmd/internal"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/tail"
"github.com/tarantool/tt/cli/util"
)

var logOpts struct {
@@ -27,12 +25,7 @@ func NewLogCmd() *cobra.Command {
var logCmd = &cobra.Command{
Use: "log [<APP_NAME> | <APP_NAME:INSTANCE_NAME>] [flags]",
Short: `Get logs of instance(s)`,
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalLogModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalLogModule),
ValidArgsFunction: func(
cmd *cobra.Command,
args []string,
9 changes: 1 addition & 8 deletions cli/cmd/logrotate.go
Original file line number Diff line number Diff line change
@@ -5,22 +5,15 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmd/internal"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/util"
)

// NewLogrotateCmd creates logrotate command.
func NewLogrotateCmd() *cobra.Command {
var logrotateCmd = &cobra.Command{
Use: "logrotate [<APP_NAME> | <APP_NAME:INSTANCE_NAME>]",
Short: "Rotate logs of a started tarantool instance(s)",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalLogrotateModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalLogrotateModule),
ValidArgsFunction: func(
cmd *cobra.Command,
args []string,
14 changes: 4 additions & 10 deletions cli/cmd/pack.go
Original file line number Diff line number Diff line change
@@ -8,29 +8,23 @@ import (
"github.com/apex/log"
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/pack"
"github.com/tarantool/tt/cli/util"
"github.com/tarantool/tt/lib/integrity"
)

// packCtx contains information for tt pack command.
var packCtx = &pack.PackCtx{}

func NewPackCmd() *cobra.Command {
var packCmd = &cobra.Command{Use: "pack TYPE [flags] ..",
var packCmd = &cobra.Command{
Use: "pack TYPE [flags] ..",
Short: "Pack application into a distributable bundle",
Long: `Pack application into a distributable bundle
The supported types are: tgz, deb, rpm`,
ValidArgs: []string{"tgz", "deb", "rpm"},
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalPackModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
Run: TtModuleCmdRun(internalPackModule),
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
}

// Common flags.
8 changes: 1 addition & 7 deletions cli/cmd/play.go
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/checkpoint"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/util"
"github.com/tarantool/tt/cli/version"
@@ -51,12 +50,7 @@ func NewPlayCmd() *cobra.Command {
var playCmd = &cobra.Command{
Use: "play (<URI> | <APP_NAME> | <APP_NAME:INSTANCE_NAME>) <FILE>...",
Short: "Play the contents of .snap/.xlog FILE(s) to another Tarantool instance",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalPlayModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalPlayModule),
Example: "tt play localhost:3013 /path/to/file.snap /path/to/file.xlog " +
"/path/to/dir/ --timestamp 2024-11-13T14:02:36.818700000+00:00\n" +
" tt play app:instance001 /path/to/file.snap /path/to/file.xlog " +
91 changes: 17 additions & 74 deletions cli/cmd/replicaset.go
Original file line number Diff line number Diff line change
@@ -11,11 +11,9 @@ import (
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/connect"
"github.com/tarantool/tt/cli/connector"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/replicaset"
replicasetcmd "github.com/tarantool/tt/cli/replicaset/cmd"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/util"
libconnect "github.com/tarantool/tt/lib/connect"
"github.com/tarantool/tt/lib/integrity"
)
@@ -66,12 +64,7 @@ func newUpgradeCmd() *cobra.Command {
Short: "Upgrade tarantool cluster",
Long: "Upgrade tarantool cluster.\n\n" +
libconnect.EnvCredentialsHelp + "\n\n",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalReplicasetUpgradeModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalReplicasetUpgradeModule),
Args: cobra.ExactArgs(1),
}

@@ -108,12 +101,7 @@ func newDowngradeCmd() *cobra.Command {
Short: "Downgrade tarantool cluster",
Long: "Downgrade tarantool cluster.\n\n" +
libconnect.EnvCredentialsHelp + "\n\n",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalReplicasetDowngradeModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalReplicasetDowngradeModule),
Args: cobra.MatchAll(cobra.ExactArgs(2), validateVersion(1)),
}

@@ -138,12 +126,7 @@ func newStatusCmd() *cobra.Command {
Short: "Show a replicaset status",
Long: "Show a replicaset status.\n\n" +
libconnect.EnvCredentialsHelp + "\n\n",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalReplicasetStatusModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalReplicasetStatusModule),
Args: cobra.ExactArgs(1),
}

@@ -162,12 +145,7 @@ func newPromoteCmd() *cobra.Command {
Short: "Promote an instance",
Long: "Promote an instance.\n\n" +
libconnect.EnvCredentialsHelp + "\n\n",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalReplicasetPromoteModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalReplicasetPromoteModule),
Args: cobra.ExactArgs(1),
}

@@ -191,13 +169,8 @@ func newDemoteCmd() *cobra.Command {
DisableFlagsInUseLine: true,
Short: "Demote an instance",
Long: "Demote an instance.",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalReplicasetDemoteModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(1),
Run: TtModuleCmdRun(internalReplicasetDemoteModule),
Args: cobra.ExactArgs(1),
}

addOrchestratorFlags(cmd)
@@ -215,13 +188,8 @@ func newExpelCmd() *cobra.Command {
"<APP_NAME:INSTANCE_NAME>",
Short: "Expel an instance from a replicaset",
Long: "Expel an instance from a replicaset.",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalReplicasetExpelModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(1),
Run: TtModuleCmdRun(internalReplicasetExpelModule),
Args: cobra.ExactArgs(1),
}

addOrchestratorFlags(cmd)
@@ -239,13 +207,8 @@ func newBootstrapCmd() *cobra.Command {
Use: "bootstrap [--timeout secs] [flags] <APP_NAME|APP_NAME:INSTANCE_NAME>",
Short: "Bootstrap an application or instance",
Long: "Bootstrap an application or instance.",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalReplicasetBootstrapModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(1),
Run: TtModuleCmdRun(internalReplicasetBootstrapModule),
Args: cobra.ExactArgs(1),
}

addOrchestratorFlags(cmd)
@@ -271,12 +234,7 @@ func newBootstrapVShardCmd() *cobra.Command {
Short: "Bootstrap vshard in the cluster",
Long: "Bootstrap vshard in the cluster.\n\n" +
libconnect.EnvCredentialsHelp + "\n\n",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalReplicasetBootstrapVShardModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalReplicasetBootstrapVShardModule),
Args: cobra.ExactArgs(1),
}

@@ -307,13 +265,8 @@ func newRebootstrapCmd() *cobra.Command {
Use: "rebootstrap <APP_NAME:INSTANCE_NAME>",
DisableFlagsInUseLine: true,
Short: "Re-bootstraps an instance",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalReplicasetRebootstrapModule, args)
util.HandleCmdErr(cmd, err)
},
Args: replicasetRebootstrapValidateArgs,
Run: TtModuleCmdRun(internalReplicasetRebootstrapModule),
Args: replicasetRebootstrapValidateArgs,
}

cmd.Flags().BoolVarP(&rebootstrapConfirmed, "yes", "y", false,
@@ -340,13 +293,8 @@ func newRolesAddCmd() *cobra.Command {
"<APP_NAME:INSTANCE_NAME> <ROLE_NAME> [flags]",
Short: "Adds a role for Cartridge and Tarantool 3 orchestrator",
Long: "Adds a role for Cartridge and Tarantool 3 orchestrator",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalReplicasetRolesAddModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(2),
Run: TtModuleCmdRun(internalReplicasetRolesAddModule),
Args: cobra.ExactArgs(2),
}

cmd.Flags().StringVarP(&replicasetReplicasetName, "replicaset", "r", "",
@@ -378,13 +326,8 @@ func newRolesRemoveCmd() *cobra.Command {
"<APP_NAME:INSTANCE_NAME> <ROLE_NAME> [flags]",
Short: "Removes a role for Cartridge and Tarantool 3 orchestrator",
Long: "Removes a role for Cartridge and Tarantool 3 orchestrator",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalReplicasetRolesRemoveModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(2),
Run: TtModuleCmdRun(internalReplicasetRolesRemoveModule),
Args: cobra.ExactArgs(2),
}

cmd.Flags().StringVarP(&replicasetReplicasetName, "replicaset", "r", "",
10 changes: 2 additions & 8 deletions cli/cmd/restart.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmd/internal"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/util"
)
@@ -22,13 +21,8 @@ func NewRestartCmd() *cobra.Command {
var restartCmd = &cobra.Command{
Use: "restart [<APP_NAME> | <APP_NAME:INSTANCE_NAME>]",
Short: "Restart tarantool instance(s)",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalRestartModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.RangeArgs(0, 1),
Run: TtModuleCmdRun(internalRestartModule),
Args: cobra.RangeArgs(0, 1),
ValidArgsFunction: func(
cmd *cobra.Command,
args []string,
9 changes: 1 addition & 8 deletions cli/cmd/rocks.go
Original file line number Diff line number Diff line change
@@ -3,9 +3,7 @@ package cmd
import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/rocks"
"github.com/tarantool/tt/cli/util"
)

// NewRocksCmd creates rocks command.
@@ -16,12 +14,7 @@ func NewRocksCmd() *cobra.Command {
// Disabled all flags parsing on this commands leaf.
// LuaRocks will handle it self.
DisableFlagParsing: true,
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalRocksModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalRocksModule),
}

return rocksCmd
11 changes: 1 addition & 10 deletions cli/cmd/run.go
Original file line number Diff line number Diff line change
@@ -3,14 +3,7 @@ package cmd
import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/util"
)

var (
// runArgs contains command args.
runArgs []string
)

func newRunInfo(cmdCtx cmdcontext.CmdCtx) *running.RunInfo {
@@ -30,15 +23,13 @@ are passed after '--'.
`,
DisableFlagParsing: true,
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
for _, opt := range args {
if opt == "-h" || opt == "--help" {
cmd.Help()
return
}
}
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo, internalRunModule, args)
util.HandleCmdErr(cmd, err)
TtModuleCmdRun(internalRunModule)(cmd, args)
},
Example: `
# Print current environment Tarantool version:
29 changes: 6 additions & 23 deletions cli/cmd/search.go
Original file line number Diff line number Diff line change
@@ -3,9 +3,7 @@ package cmd
import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/search"
"github.com/tarantool/tt/cli/util"
)

var (
@@ -21,13 +19,8 @@ func newSearchTtCmd() *cobra.Command {
var tntCmd = &cobra.Command{
Use: "tt",
Short: "Search for available tt versions",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalSearchModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(0),
Run: TtModuleCmdRun(internalSearchModule),
Args: cobra.ExactArgs(0),
}

return tntCmd
@@ -38,13 +31,8 @@ func newSearchTarantoolCmd() *cobra.Command {
var tntCmd = &cobra.Command{
Use: "tarantool",
Short: "Search for available tarantool community edition versions",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalSearchModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(0),
Run: TtModuleCmdRun(internalSearchModule),
Args: cobra.ExactArgs(0),
}

return tntCmd
@@ -55,13 +43,8 @@ func newSearchTarantoolEeCmd() *cobra.Command {
var tntCmd = &cobra.Command{
Use: "tarantool-ee",
Short: "Search for available tarantool enterprise edition versions",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalSearchModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(0),
Run: TtModuleCmdRun(internalSearchModule),
Args: cobra.ExactArgs(0),
}
tntCmd.Flags().BoolVar(&debug, "debug", debug,
"search for debug builds of tarantool-ee SDK")
9 changes: 1 addition & 8 deletions cli/cmd/start.go
Original file line number Diff line number Diff line change
@@ -13,10 +13,8 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmd/internal"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/tail"
"github.com/tarantool/tt/cli/util"
"github.com/tarantool/tt/lib/integrity"
)

@@ -39,12 +37,7 @@ func NewStartCmd() *cobra.Command {
var startCmd = &cobra.Command{
Use: "start [<APP_NAME> | <APP_NAME:INSTANCE_NAME>]",
Short: "Start tarantool instance(s)",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalStartModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalStartModule),
ValidArgsFunction: func(
cmd *cobra.Command,
args []string,
9 changes: 1 addition & 8 deletions cli/cmd/status.go
Original file line number Diff line number Diff line change
@@ -4,10 +4,8 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmd/internal"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/status"
"github.com/tarantool/tt/cli/util"
)

var opts status.StatusOpts
@@ -32,12 +30,7 @@ Columns:
- CONFIG: The config info status (for Tarantool 3+).
- BOX: The box info status.
- UPSTREAM: The replication upstream status.`,
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalStatusModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalStatusModule),
ValidArgsFunction: func(
cmd *cobra.Command,
args []string,
10 changes: 2 additions & 8 deletions cli/cmd/stop.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmd/internal"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/running"
"github.com/tarantool/tt/cli/util"
)
@@ -18,13 +17,8 @@ func NewStopCmd() *cobra.Command {
var stopCmd = &cobra.Command{
Use: "stop [<APP_NAME> | <APP_NAME:INSTANCE_NAME>]",
Short: "Stop tarantool instance(s)",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalStopWithConfirmationModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.RangeArgs(0, 1),
Run: TtModuleCmdRun(internalStopWithConfirmationModule),
Args: cobra.RangeArgs(0, 1),
ValidArgsFunction: func(
cmd *cobra.Command,
args []string,
38 changes: 8 additions & 30 deletions cli/cmd/uninstall.go
Original file line number Diff line number Diff line change
@@ -3,23 +3,16 @@ package cmd
import (
"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/uninstall"
"github.com/tarantool/tt/cli/util"
)

// newUninstallTtCmd creates a command to install tt.
func newUninstallTtCmd() *cobra.Command {
var tntCmd = &cobra.Command{
Use: "tt [version]",
Short: "Uninstall tt",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
InternalUninstallModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.MaximumNArgs(1),
Run: TtModuleCmdRun(InternalUninstallModule),
Args: cobra.MaximumNArgs(1),
ValidArgsFunction: func(
cmd *cobra.Command,
args []string,
@@ -40,13 +33,8 @@ func newUninstallTarantoolCmd() *cobra.Command {
var tntCmd = &cobra.Command{
Use: "tarantool [version]",
Short: "Uninstall tarantool community edition",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
InternalUninstallModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.MaximumNArgs(1),
Run: TtModuleCmdRun(InternalUninstallModule),
Args: cobra.MaximumNArgs(1),
ValidArgsFunction: func(
cmd *cobra.Command,
args []string,
@@ -67,13 +55,8 @@ func newUninstallTarantoolEeCmd() *cobra.Command {
var tntCmd = &cobra.Command{
Use: "tarantool-ee [version]",
Short: "Uninstall tarantool enterprise edition",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
InternalUninstallModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.MaximumNArgs(1),
Run: TtModuleCmdRun(InternalUninstallModule),
Args: cobra.MaximumNArgs(1),
ValidArgsFunction: func(
cmd *cobra.Command,
args []string,
@@ -94,13 +77,8 @@ func newUninstallTarantoolDevCmd() *cobra.Command {
tntCmd := &cobra.Command{
Use: "tarantool-dev",
Short: "Uninstall tarantool-dev",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
InternalUninstallModule, args)
util.HandleCmdErr(cmd, err)
},
Args: cobra.ExactArgs(0),
Run: TtModuleCmdRun(InternalUninstallModule),
Args: cobra.ExactArgs(0),
}

return tntCmd
9 changes: 1 addition & 8 deletions cli/cmd/version.go
Original file line number Diff line number Diff line change
@@ -5,8 +5,6 @@ import (

"github.com/spf13/cobra"
"github.com/tarantool/tt/cli/cmdcontext"
"github.com/tarantool/tt/cli/modules"
"github.com/tarantool/tt/cli/util"
"github.com/tarantool/tt/cli/version"
)

@@ -20,12 +18,7 @@ func NewVersionCmd() *cobra.Command {
var versionCmd = &cobra.Command{
Use: "version",
Short: "Show Tarantool CLI version information",
Run: func(cmd *cobra.Command, args []string) {
cmdCtx.CommandName = cmd.Name()
err := modules.RunCmd(&cmdCtx, cmd.CommandPath(), &modulesInfo,
internalVersionModule, args)
util.HandleCmdErr(cmd, err)
},
Run: TtModuleCmdRun(internalVersionModule),
}

versionCmd.Flags().BoolVar(&showShort, "short", false, "Show version in short format")