Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/grpc-error-…
Browse files Browse the repository at this point in the history
…handling

* origin/master:
  chore(release): 2.12.2
  fix: context printer is plain by default and missing json pretty (#110)
  • Loading branch information
trietsch committed Aug 18, 2022
2 parents 0641bf8 + f8e1d9f commit 844e1ca
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [2.12.2](https://github.com/strmprivacy/cli/compare/v2.12.1...v2.12.2) (2022-08-18)


### Bug Fixes

* context printer is plain by default and missing json pretty ([#110](https://github.com/strmprivacy/cli/issues/110)) ([d69431c](https://github.com/strmprivacy/cli/commit/d69431c41a66855ed1d1390fc8c2da08dd3f82ee))

## [2.12.1](https://github.com/strmprivacy/cli/compare/v2.12.0...v2.12.1) (2022-08-17)


Expand Down
2 changes: 1 addition & 1 deletion pkg/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var ContextOutputFormatFlagAllowedValuesText = strings.Join(ContextOutputFormatF
var ConfigOutputFormatFlagAllowedValues = []string{OutputFormatPlain, OutputFormatJson}
var ConfigOutputFormatFlagAllowedValuesText = strings.Join(ConfigOutputFormatFlagAllowedValues, ", ")

var AccountOutputFormatFlagAllowedValues = []string{OutputFormatPlain, OutputFormatJsonRaw}
var AccountOutputFormatFlagAllowedValues = []string{OutputFormatPlain, OutputFormatJson, OutputFormatJsonRaw}
var AccountOutputFormatFlagAllowedValuesText = strings.Join(AccountOutputFormatFlagAllowedValues, ", ")

var ProjectOutputFormatFlagAllowedValues = []string{OutputFormatPlain}
Expand Down
2 changes: 1 addition & 1 deletion pkg/context/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func Account() *cobra.Command {
cmd.Flags().StringP(
common.OutputFormatFlag,
common.OutputFormatFlagShort,
common.OutputFormatJsonRaw,
common.OutputFormatPlain,
fmt.Sprintf("Configuration output format [%v]", common.AccountOutputFormatFlagAllowedValuesText),
)
err := cmd.RegisterFlagCompletionFunc(common.OutputFormatFlag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
Expand Down
18 changes: 5 additions & 13 deletions pkg/context/printers.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ func availablePrinters() map[string]util.Printer {
common.OutputFormatFilepath + entityInfoCommandName: filepathPrinter{},
common.OutputFormatPlain + configCommandName: configPlainPrinter{},
common.OutputFormatJson + configCommandName: configJsonPrinter{},
common.OutputFormatJsonRaw + accountCommandName: accountJsonPrinter{},
common.OutputFormatJson + accountCommandName: util.ProtoMessageJsonPrettyPrinter{},
common.OutputFormatJsonRaw + accountCommandName: util.ProtoMessageJsonRawPrinter{},
common.OutputFormatPlain + accountCommandName: accountPlainPrinter{},
common.OutputFormatPlain + projectCommandName: projectPrinter{},
}
Expand All @@ -58,7 +59,6 @@ type filepathPrinter struct{}
type jsonRawPrinter struct{}
type jsonPrettyPrinter struct{}
type configPlainPrinter struct{}
type accountJsonPrinter struct{}
type accountPlainPrinter struct{}
type configJsonPrinter struct{}
type projectPrinter struct{}
Expand All @@ -81,19 +81,11 @@ func (p jsonPrettyPrinter) Print(data interface{}) {
fmt.Println(string(prettyJson.Bytes()))
}

func (p accountJsonPrinter) Print(data interface{}) {
entity, _ := (data).(*account.GetAccountDetailsResponse)
b, _ := json.Marshal(entity)
rawJson := util.CompactJson(b)
fmt.Println(string(rawJson.Bytes()))
}

func (p accountPlainPrinter) Print(data interface{}) {
entity, _ := (data).(*account.GetAccountDetailsResponse)
fmt.Println(fmt.Sprintf("max_input_streams: %v", entity.MaxInputStreams))
fmt.Println(fmt.Sprintf("handle: %v", entity.Handle))
fmt.Println(fmt.Sprintf("subscription: %v", entity.Subscription))

fmt.Println(fmt.Sprintf("Max Input Streams: %v", entity.MaxInputStreams))
fmt.Println(fmt.Sprintf("Handle (used for contracts and schemas): %v", entity.Handle))
fmt.Println(fmt.Sprintf("Subscription type: %v", entity.Subscription))
}

func (p configPlainPrinter) Print(data interface{}) {
Expand Down

0 comments on commit 844e1ca

Please sign in to comment.