cli
cli copied to clipboard
fix(template): remove `client.ReadPersistentCommandFlags`
The client.SetCmdClientContextHandler has the client.ReadPersistentCommandFlags
https://github.com/cosmos/cosmos-sdk/blob/0c91044220403e7b899ad0e51ccd2d4e5d66a901/client/cmd.go#L30-L37
Now that your changes (https://github.com/cosmos/cosmos-sdk/pull/20356) have been merged and backported to v0.50 in the SDK, let me check if this works now.
the steps to initialize the client instance:
- use the depinject
- add cobra cmd
- read the flags (I removed this)
- read the config file
- add tx config (it doesn't depend on step 3)
- read the flags again in the
SetCmdClientContextHandler
I don't think the step 3 is necessary.
and by the way, refer to the viper documentation, the flag has higher priority
https://github.com/spf13/viper?tab=readme-ov-file#why-viper
This is required, otherwise ReadFromClientConfig will have a client context with possibly wrong values (such as the home) or the output.