mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 22:55:06 +03:00
Move yggdrasilctl request switch to separate function
This commit is contained in:
parent
fa65253e57
commit
215351aefc
1 changed files with 37 additions and 31 deletions
|
@ -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{}) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue