Skip to content

Commit 997becd

Browse files
committed
Fix arguments parsing if internal command is forced over external
Closes #1134 @TarantoolBot document Title: Fix arguments parsing if internal command is forced over external
1 parent b3870d0 commit 997becd

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2020

2121
### Fixed
2222

23+
- Arguments of an internal command are not parsed if it is forced over its existent
24+
external counterpart.
25+
2326
## [2.8.1] - 2025-03-10
2427

2528
The release introduces minor changes in stabilization of `tt connect`

cli/cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ func InitRoot() {
314314
// External commands must be configured in a special way.
315315
// This is necessary, for example, so that we can pass arguments to these commands.
316316
if len(os.Args) > 1 {
317-
configure.ExternalCmd(rootCmd, &cmdCtx, &modulesInfo, os.Args[1:])
317+
configure.ExternalCmd(rootCmd, &cmdCtx, &modulesInfo, cmdCtx.Cli.ForceInternal, os.Args[1:])
318318
}
319319

320320
// Configure help command.

cli/configure/configure.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,17 +438,18 @@ func Cli(cmdCtx *cmdcontext.CmdCtx) error {
438438

439439
// ExternalCmd configures external commands.
440440
func ExternalCmd(rootCmd *cobra.Command, cmdCtx *cmdcontext.CmdCtx,
441-
modulesInfo *modules.ModulesInfo, args []string) {
442-
configureExistsCmd(rootCmd, modulesInfo)
441+
modulesInfo *modules.ModulesInfo, forceInternal bool, args []string) {
442+
configureExistsCmd(rootCmd, modulesInfo, forceInternal)
443443
configureNonExistentCmd(rootCmd, cmdCtx, modulesInfo, args)
444444
}
445445

446446
// configureExistsCmd configures an external commands
447447
// that have internal implementation.
448-
func configureExistsCmd(rootCmd *cobra.Command, modulesInfo *modules.ModulesInfo) {
448+
func configureExistsCmd(rootCmd *cobra.Command, modulesInfo *modules.ModulesInfo,
449+
forceInternal bool) {
449450
for _, cmd := range rootCmd.Commands() {
450451
if _, found := (*modulesInfo)[cmd.CommandPath()]; found {
451-
cmd.DisableFlagParsing = true
452+
cmd.DisableFlagParsing = !forceInternal
452453
}
453454
}
454455
}
Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
import re
22

3-
from utils import run_command_and_get_output
3+
import utils
44

55

6-
def test_version_cmd(tt_cmd, tmp_path):
6+
def check_internal_version_cmd(tt_cmd, tmp_path):
77
cmd = [tt_cmd, "-I", "version"]
8-
rc, output = run_command_and_get_output(cmd, cwd=tmp_path)
8+
rc, output = utils.run_command_and_get_output(cmd, cwd=tmp_path)
99
assert rc == 0
1010
assert len(re.findall(r"(\s\d+.\d+.\d+,|\s<unknown>,)", output)) == 1
1111

1212
cmd = [tt_cmd, "-I", "version", "--short"]
13-
rc, output = run_command_and_get_output(cmd, cwd=tmp_path)
13+
rc, output = utils.run_command_and_get_output(cmd, cwd=tmp_path)
1414
assert rc == 0
1515
assert re.match(r"(\d+.\d+.\d+|<unknown>)", output)
1616

1717
cmd = [tt_cmd, "-I", "version", "--commit"]
18-
rc, output = run_command_and_get_output(cmd, cwd=tmp_path)
18+
rc, output = utils.run_command_and_get_output(cmd, cwd=tmp_path)
1919
assert rc == 0
2020
assert re.match(r"(\d+.\d+.\d+|<unknown>).\w+", output)
2121

2222
cmd = [tt_cmd, "-I", "version", "--commit", "--short"]
23-
rc, output = run_command_and_get_output(cmd, cwd=tmp_path)
23+
rc, output = utils.run_command_and_get_output(cmd, cwd=tmp_path)
2424
assert rc == 0
2525
assert re.match(r"(\d+.\d+.\d+|<unknown>).\w+", output)
26+
27+
28+
def test_version_cmd(tt_cmd, tmp_path):
29+
check_internal_version_cmd(tt_cmd, tmp_path)
30+
31+
32+
def test_version_internal_over_external(tt_cmd, tmp_path):
33+
utils.create_external_module("version", tmp_path)
34+
utils.create_tt_config(tmp_path, tmp_path)
35+
check_internal_version_cmd(tt_cmd, tmp_path)

0 commit comments

Comments
 (0)