tendermint/spm

fix stderr/stdout in cli

Closed this issue · 6 comments

currently everything is sent to stderr and its breaking export and other cli commands having to hack it.

PersistentPreRun in the root command should have

// set the default command outputs
cmd.SetOut(cmd.OutOrStdout())
cmd.SetErr(cmd.ErrOrStderr())

What's your use case? maybe I can help you to figure out another solution. Some outputs by the cosmos-sdk are printed into the stderr, this is the reason we were parsing the stderr outputs

This is a misconfiguration in spm see https://github.com/cosmos/cosmos-sdk/blob/cc1a1c8cd0b0853f24f785d52822bb7e71ee572b/simapp/simd/cmd/root.go#L56

Even if the command is set to send output to stdout is being sent to stderr which prevents integrating with pipes which is very much how you interact with jq or other pipe like appd tx ... --generate-only > tx.json.

appd export > genesis.json will just print everything to the console.

Currently without this you have to do appd [command] 2>&1 | jq all the time which is far from ideal

Is this change works for your case? Did you test it? Because I think it's more tricky for the starport. The cosmos-SDK only uses it for the simapp (chain simulation), starport uses different logic to run the chain binary and get the information from the SDK.

Works for us in production public-awesome@f598fd5

But you can try it with multiple commands with a starport chain and try to pipe to a file or to jq it's painful.

Great!! It would be awesome if you could create the PR with these changes for we can test to add in the following versions

Sure will open a PR