Skip to content

Commit

Permalink
Added some human-friendly outputs (#759)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar-connect authored Jul 26, 2022
1 parent 571ae88 commit 990c791
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cmd/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func NewCommand(config *settings.Config, preRunE validator.Validator) *cobra.Com
return fmt.Errorf("failed to create policy: %w", err)
}

_, _ = io.WriteString(cmd.ErrOrStderr(), "Policy Created Successfully\n")

if err := prettyJSONEncoder(cmd.OutOrStdout()).Encode(result); err != nil {
return fmt.Errorf("failed to encode result to stdout: %w", err)
}
Expand Down Expand Up @@ -129,7 +131,7 @@ func NewCommand(config *settings.Config, preRunE validator.Validator) *cobra.Com
if err != nil {
return fmt.Errorf("failed to delete policy: %v", err)
}
_, _ = io.WriteString(cmd.OutOrStdout(), "Deleted Successfully\n")
_, _ = io.WriteString(cmd.ErrOrStderr(), "Policy Deleted Successfully\n")
return nil
},
Args: cobra.ExactArgs(1),
Expand Down Expand Up @@ -170,6 +172,8 @@ func NewCommand(config *settings.Config, preRunE validator.Validator) *cobra.Com
return fmt.Errorf("failed to update policy: %w", err)
}

_, _ = io.WriteString(cmd.ErrOrStderr(), "Policy Updated Successfully\n")

if err := prettyJSONEncoder(cmd.OutOrStdout()).Encode(result); err != nil {
return fmt.Errorf("failed to encode result to stdout: %w", err)
}
Expand Down
1 change: 0 additions & 1 deletion cmd/policy/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ func TestDeletePolicy(t *testing.T) {
assert.Equal(t, r.URL.String(), "/api/v1/owner/462d67f8-b232-4da4-a7de-0c86dd667d3f/policy/60b7e1a5-c1d7-4422-b813-7a12d353d7c6")
w.WriteHeader(http.StatusNoContent)
},
ExpectedOutput: "Deleted Successfully\n",
},
}

Expand Down

0 comments on commit 990c791

Please sign in to comment.