handle json formatting for print

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2024-04-01 16:46:04 -07:00
parent c690d460e8
commit 858e347306
No known key found for this signature in database
GPG Key ID: AFA9DE5F8AB7AF39
1 changed files with 3 additions and 1 deletions

View File

@ -855,7 +855,9 @@ func printResult(f *controllerapi.PrintFunc, res map[string]string) error {
case "subrequests.describe":
return printValue(subrequests.PrintDescribe, subrequests.SubrequestsDescribeDefinition.Version, f.Format, res)
default:
if dt, ok := res["result.txt"]; ok {
if dt, ok := res["result.json"]; ok && f.Format == "json" {
fmt.Println(dt)
} else if dt, ok := res["result.txt"]; ok {
fmt.Print(dt)
} else {
log.Printf("%s %+v", f, res)