From b14c74e6270c4e2fdd9741c3cbe619336efd1435 Mon Sep 17 00:00:00 2001 From: Aeneas Date: Fri, 24 Nov 2017 15:05:40 +0100 Subject: [PATCH] Print formatted output string in rule management CLI (#35) --- cmd/helper_response.go | 2 +- cmd/rules_get.go | 6 ++++-- cmd/rules_list.go | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/helper_response.go b/cmd/helper_response.go index 052ab280bb..82805dac24 100644 --- a/cmd/helper_response.go +++ b/cmd/helper_response.go @@ -9,7 +9,7 @@ import ( ) func checkResponse(response *swagger.APIResponse, err error, expectedStatusCode int) { - must(err, "Could not validate token: %s", err) + must(err, "A network error occurred: %s", err) if response.StatusCode != expectedStatusCode { fmt.Printf("Command failed because status code %d was expeceted but code %d was received", expectedStatusCode, response.StatusCode) diff --git a/cmd/rules_get.go b/cmd/rules_get.go index 892425ce73..91ca40eaa1 100644 --- a/cmd/rules_get.go +++ b/cmd/rules_get.go @@ -3,6 +3,8 @@ package cmd import ( "net/http" + "fmt" + "github.com/ory/oathkeeper/sdk/go/oathkeepersdk" "github.com/spf13/cobra" ) @@ -24,9 +26,9 @@ var getCmd = &cobra.Command{ } client := oathkeepersdk.NewSDK(endpoint) - rules, response, err := client.GetRule(args[0]) + rule, response, err := client.GetRule(args[0]) checkResponse(response, err, http.StatusOK) - formatResponse(rules) + fmt.Println(formatResponse(rule)) }, } diff --git a/cmd/rules_list.go b/cmd/rules_list.go index 1e9e7ccc9b..39e0a3878f 100644 --- a/cmd/rules_list.go +++ b/cmd/rules_list.go @@ -3,6 +3,8 @@ package cmd import ( "net/http" + "fmt" + "github.com/ory/oathkeeper/sdk/go/oathkeepersdk" "github.com/spf13/cobra" ) @@ -24,7 +26,7 @@ var listCmd = &cobra.Command{ client := oathkeepersdk.NewSDK(endpoint) rules, response, err := client.ListRules() checkResponse(response, err, http.StatusOK) - formatResponse(rules) + fmt.Println(formatResponse(rules)) }, }