mirror of
https://github.com/docker/compose.git
synced 2025-07-23 21:54:40 +02:00
TC: Use map to simplify flag conversion and avoid multilple if statements
Signed-off-by: ThedosiouTh <thanosthd@gmail.com>
This commit is contained in:
parent
5b6b674da9
commit
40f0dbd971
@ -43,6 +43,15 @@ func getStringFlags() []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var argToActualFlag = 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
|
// Convert transforms standalone docker-compose args into CLI plugin compliant ones
|
||||||
func Convert(args []string) []string {
|
func Convert(args []string) []string {
|
||||||
var rootFlags []string
|
var rootFlags []string
|
||||||
@ -58,16 +67,8 @@ func Convert(args []string) []string {
|
|||||||
command = append(command, args[i:]...)
|
command = append(command, args[i:]...)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if arg == "--verbose" {
|
if actualFlag, ok := argToActualFlag[arg]; ok {
|
||||||
arg = "--debug"
|
arg = actualFlag
|
||||||
}
|
|
||||||
if arg == "-h" {
|
|
||||||
// docker cli has deprecated -h to avoid ambiguity with -H, while docker-compose still support it
|
|
||||||
arg = "--help"
|
|
||||||
}
|
|
||||||
if arg == "--version" || arg == "-v" {
|
|
||||||
// redirect --version pseudo-command to actual command
|
|
||||||
arg = "version"
|
|
||||||
}
|
}
|
||||||
if contains(getBoolFlags(), arg) {
|
if contains(getBoolFlags(), arg) {
|
||||||
rootFlags = append(rootFlags, arg)
|
rootFlags = append(rootFlags, arg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user