diff --git a/cmd/command_Post.go b/cmd/command_Post.go index fe01ffb..4734513 100644 --- a/cmd/command_Post.go +++ b/cmd/command_Post.go @@ -97,6 +97,35 @@ func commandRunPost(cmd *cobra.Command, command SchemaCommand) { } commandRunSsh(cmd, command, body, publicKey) os.Exit(exitCodeUnexpected) + } else if command.Run.SimpleJsonServerResponse { + if format == "json" { + fmt.Println(string(body)) + os.Exit(0) + } else { + var response map[string]string + if err := json.Unmarshal(body, &response); err != nil { + fmt.Println(string(body)) + fmt.Println("Failed to parse server response") + os.Exit(exitCodeInvalidResponse) + } else if format == "yaml" { + var d []byte + d, err = yaml.Marshal(&response) + if err != nil { + fmt.Println(string(body)) + fmt.Println("Invalid response from server") + os.Exit(exitCodeInvalidResponse) + } else { + fmt.Println(string(d)) + os.Exit(0) + } + } else { + message, hasMessage := response["message"] + if hasMessage { + fmt.Println(message) + os.Exit(0) + } + } + } } else { var commandIds []string; if err := json.Unmarshal(body, &commandIds); err != nil { diff --git a/cmd/command_schema.go b/cmd/command_schema.go index 8469892..fc8009e 100644 --- a/cmd/command_schema.go +++ b/cmd/command_schema.go @@ -74,6 +74,7 @@ type SchemaCommandRun struct { Lists []SchemaCommandList `json:"lists"` ServerMethod string `json:"serverMethod"` ParseStatisticsResponse bool `json:"ParseStatisticsResponse"` + SimpleJsonServerResponse bool `json:"SimpleJsonServerResponse"` } type SchemaCommandCliPreRunHook struct { @@ -104,7 +105,13 @@ type Schema struct { SchemaGeneratedAt time.Time `json:"schema_generated_at"` } +func getSupportsParam() string { + // comma-separated list of cloudcli-server functionality this cli version supports + return "SimpleJsonServerResponse" +} + func downloadSchema(schemaFile string, schemaUrl string) Schema { + schemaUrl = fmt.Sprintf("%s?supports=%s", schemaUrl, getSupportsParam()) var schema_ Schema if dryrun || debug { if debug {