Skip to content

Commit 115ac6d

Browse files
committed
Use switch/case instead of static map for simplicity
Signed-off-by: ThedosiouTh <[email protected]>
1 parent 8648f30 commit 115ac6d

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

cmd/compatibility/convert.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,6 @@ func getStringFlags() []string {
4343
}
4444
}
4545

46-
var argToActualArgument = map[string]string{
47-
"--verbose": "--debug",
48-
// docker cli has deprecated -h to avoid ambiguity with -H, while docker-compose still support it
49-
"-h": "--help",
50-
// redirect --version pseudo-command to actual command
51-
"--version": "version",
52-
"-v": "version",
53-
}
54-
5546
// Convert transforms standalone docker-compose args into CLI plugin compliant ones
5647
func Convert(args []string) []string {
5748
var rootFlags []string
@@ -67,9 +58,18 @@ func Convert(args []string) []string {
6758
command = append(command, args[i:]...)
6859
break
6960
}
70-
if actualArgument, ok := argToActualArgument[arg]; ok {
71-
arg = actualArgument
61+
62+
switch arg {
63+
case "--verbose":
64+
arg = "--debug"
65+
case "-h":
66+
// docker cli has deprecated -h to avoid ambiguity with -H, while docker-compose still support it
67+
arg = "--help"
68+
case "--version", "-v":
69+
// redirect --version pseudo-command to actual command
70+
arg = "version"
7271
}
72+
7373
if contains(getBoolFlags(), arg) {
7474
rootFlags = append(rootFlags, arg)
7575
continue

0 commit comments

Comments
 (0)