Move yggdrasilctl request switch to separate function

This commit is contained in:
Alex Kotov 2021-07-22 23:24:21 +05:00
parent fa65253e57
commit 215351aefc

View file

@ -195,7 +195,6 @@ func run() int {
fmt.Println("Missing response body (malformed response?)")
return 1
}
req := recv["request"].(map[string]interface{})
res := recv["response"].(map[string]interface{})
if *injson {
@ -205,6 +204,21 @@ func run() int {
return 0
}
runAll(recv, verbose)
} else {
logger.Println("Error receiving response:", err)
}
if v, ok := recv["status"]; ok && v != "success" {
return 1
}
return 0
}
func runAll(recv map[string]interface{}, verbose *bool) {
req := recv["request"].(map[string]interface{})
res := recv["response"].(map[string]interface{})
switch strings.ToLower(req["request"].(string)) {
case "dot":
runDot(res)
@ -235,14 +249,6 @@ func run() int {
fmt.Println(string(json))
}
}
} else {
logger.Println("Error receiving response:", err)
}
if v, ok := recv["status"]; ok && v != "success" {
return 1
}
return 0
}
func runDot(res map[string]interface{}) {