diff --git a/hermes/cmd/hermes_configure.go b/hermes/cmd/hermes_configure.go index cdc1ec59..2b4ad781 100644 --- a/hermes/cmd/hermes_configure.go +++ b/hermes/cmd/hermes_configure.go @@ -280,6 +280,7 @@ func hermesConfigureHandler(cmd *cobra.Command, args []string) error { chainBID, hermes.WithConfigFile(cfgPath), hermes.WithStdOut(&bufClientAResult), + hermes.WithJSONOutput(), ); err != nil { return err } @@ -305,6 +306,7 @@ func hermesConfigureHandler(cmd *cobra.Command, args []string) error { chainAID, hermes.WithConfigFile(cfgPath), hermes.WithStdOut(&bufClientBResult), + hermes.WithJSONOutput(), ); err != nil { return err } @@ -332,6 +334,7 @@ func hermesConfigureHandler(cmd *cobra.Command, args []string) error { clientBResult.CreateClient.ClientID, hermes.WithConfigFile(cfgPath), hermes.WithStdOut(&bufConnection), + hermes.WithJSONOutput(), ); err != nil { return err } @@ -361,6 +364,7 @@ func hermesConfigureHandler(cmd *cobra.Command, args []string) error { chainBPortID, hermes.WithConfigFile(cfgPath), hermes.WithStdOut(&bufChannel), + hermes.WithJSONOutput(), ); err != nil { return err } @@ -427,6 +431,7 @@ GetKey: chainID, hermes.WithConfigFile(cfgPath), hermes.WithStdOut(&bufKeysChain), + hermes.WithJSONOutput(), ); err != nil { return "", err } @@ -474,6 +479,7 @@ GetKey: mnemonic, hermes.WithConfigFile(cfgPath), hermes.WithStdOut(&bufKeysChainAdd), + hermes.WithJSONOutput(), ); err != nil { return "", err } diff --git a/hermes/pkg/hermes/hermes.go b/hermes/pkg/hermes/hermes.go index 3f4514ee..03d43466 100644 --- a/hermes/pkg/hermes/hermes.go +++ b/hermes/pkg/hermes/hermes.go @@ -96,12 +96,13 @@ type ( // configs holds Generate configs. configs struct { - flags Flags - config string - args []string - stdin io.Reader - stdout io.Writer - stderr io.Writer + flags Flags + config string + args []string + stdin io.Reader + stdout io.Writer + stderr io.Writer + jsonOutput bool } ) @@ -207,6 +208,13 @@ func WithStdIn(stdin io.Reader) Option { } } +// WithJSONOutput add a json output. +func WithJSONOutput() Option { + return func(c *configs) { + c.jsonOutput = true + } +} + // WithStdOut add a std output. func WithStdOut(stdout io.Writer) Option { return func(c *configs) { @@ -391,7 +399,9 @@ func (h *Hermes) Run(ctx context.Context, options ...Option) error { if c.config != "" { cmd = append(cmd, fmt.Sprintf("--%s=%s", FlagConfig, c.config)) } - cmd = append(cmd, "--json") + if c.jsonOutput { + cmd = append(cmd, "--json") + } cmd = append(cmd, c.args...) for flag, value := range c.flags {