@@ -6,15 +6,12 @@ import (
6
6
"os/exec"
7
7
"path/filepath"
8
8
"reflect"
9
- "strings"
10
9
"syscall"
11
10
12
11
"github.com/apex/log"
13
12
"github.com/mitchellh/mapstructure"
14
- "github.com/spf13/cobra"
15
13
"github.com/tarantool/tt/cli/cmdcontext"
16
14
"github.com/tarantool/tt/cli/config"
17
- "github.com/tarantool/tt/cli/modules"
18
15
"github.com/tarantool/tt/cli/util"
19
16
"github.com/tarantool/tt/lib/integrity"
20
17
)
@@ -436,78 +433,6 @@ func Cli(cmdCtx *cmdcontext.CmdCtx) error {
436
433
return configureDefaultCli (cmdCtx )
437
434
}
438
435
439
- // ExternalCmd configures external commands.
440
- func ExternalCmd (rootCmd * cobra.Command , cmdCtx * cmdcontext.CmdCtx ,
441
- modulesInfo * modules.ModulesInfo , forceInternal bool , args []string ) {
442
- configureExistsCmd (rootCmd , modulesInfo , forceInternal )
443
- configureNonExistentCmd (rootCmd , cmdCtx , modulesInfo , args )
444
- }
445
-
446
- // configureExistsCmd configures an external commands
447
- // that have internal implementation.
448
- func configureExistsCmd (rootCmd * cobra.Command , modulesInfo * modules.ModulesInfo ,
449
- forceInternal bool ) {
450
- for _ , cmd := range rootCmd .Commands () {
451
- if _ , found := (* modulesInfo )[cmd .CommandPath ()]; found {
452
- cmd .DisableFlagParsing = ! forceInternal
453
- }
454
- }
455
- }
456
-
457
- // configureNonExistentCmd configures an external command that
458
- // has no internal implementation within the Tarantool CLI.
459
- func configureNonExistentCmd (rootCmd * cobra.Command , cmdCtx * cmdcontext.CmdCtx ,
460
- modulesInfo * modules.ModulesInfo , args []string ) {
461
- // Since the user can pass flags, to determine the name of
462
- // an external command we have to take the first non-flag argument.
463
- externalCmd := args [0 ]
464
- for _ , name := range args {
465
- if ! strings .HasPrefix (name , "-" ) && name != "help" {
466
- externalCmd = name
467
- break
468
- }
469
- }
470
-
471
- // We avoid overwriting existing commands - we should add a command only
472
- // if it doesn't have an internal implementation in Tarantool CLI.
473
- for _ , cmd := range rootCmd .Commands () {
474
- if cmd .Name () == externalCmd {
475
- return
476
- }
477
- }
478
-
479
- helpCmd := util .GetHelpCommand (rootCmd )
480
- externalCmdPath := rootCmd .Name () + " " + externalCmd
481
- if _ , found := (* modulesInfo )[externalCmdPath ]; found {
482
- rootCmd .AddCommand (newExternalCommand (cmdCtx , modulesInfo , externalCmd ,
483
- externalCmdPath , nil ))
484
- helpCmd .AddCommand (newExternalCommand (cmdCtx , modulesInfo , externalCmd , externalCmdPath ,
485
- []string {"--help" }))
486
- }
487
- }
488
-
489
- // newExternalCommand returns a pointer to a new external
490
- // command that will call modules.RunCmd.
491
- func newExternalCommand (cmdCtx * cmdcontext.CmdCtx , modulesInfo * modules.ModulesInfo ,
492
- cmdName , cmdPath string , addArgs []string ) * cobra.Command {
493
- cmd := & cobra.Command {
494
- Use : cmdName ,
495
- Run : func (cmd * cobra.Command , args []string ) {
496
- if addArgs != nil {
497
- args = append (args , addArgs ... )
498
- }
499
-
500
- cmdCtx .Cli .ForceInternal = false
501
- if err := modules .RunCmd (cmdCtx , cmdPath , modulesInfo , nil , args ); err != nil {
502
- log .Fatalf (err .Error ())
503
- }
504
- },
505
- }
506
-
507
- cmd .DisableFlagParsing = true
508
- return cmd
509
- }
510
-
511
436
// detectLocalTarantool searches for available Tarantool executable.
512
437
func detectLocalTarantool (cmdCtx * cmdcontext.CmdCtx , cliOpts * config.CliOpts ) error {
513
438
localTarantool , err := util .JoinAbspath (cliOpts .Env .BinDir , "tarantool" )
0 commit comments