Use switch/case instead of static map for simplicity

Signed-off-by: ThedosiouTh <thanosthd@gmail.com>
This commit is contained in:
ThedosiouTh 2022-06-30 18:49:28 +03:00
parent 8648f30351
commit 115ac6d529
1 changed files with 11 additions and 11 deletions

View File

@ -43,15 +43,6 @@ func getStringFlags() []string {
}
}
var argToActualArgument = map[string]string{
"--verbose": "--debug",
// docker cli has deprecated -h to avoid ambiguity with -H, while docker-compose still support it
"-h": "--help",
// redirect --version pseudo-command to actual command
"--version": "version",
"-v": "version",
}
// Convert transforms standalone docker-compose args into CLI plugin compliant ones
func Convert(args []string) []string {
var rootFlags []string
@ -67,9 +58,18 @@ func Convert(args []string) []string {
command = append(command, args[i:]...)
break
}
if actualArgument, ok := argToActualArgument[arg]; ok {
arg = actualArgument
switch arg {
case "--verbose":
arg = "--debug"
case "-h":
// docker cli has deprecated -h to avoid ambiguity with -H, while docker-compose still support it
arg = "--help"
case "--version", "-v":
// redirect --version pseudo-command to actual command
arg = "version"
}
if contains(getBoolFlags(), arg) {
rootFlags = append(rootFlags, arg)
continue