Update root command setup to respect home flag #34

Merged
ashwin merged 2 commits from pm-handle-config-resolution into main 2024-07-10 12:32:50 +00:00

View File

@ -68,7 +68,7 @@ func NewRootCmd() *cobra.Command {
cmd.SetOut(cmd.OutOrStdout()) cmd.SetOut(cmd.OutOrStdout())
cmd.SetErr(cmd.ErrOrStderr()) cmd.SetErr(cmd.ErrOrStderr())
clientCtx = clientCtx.WithCmdContext(cmd.Context()) clientCtx = clientCtx.WithCmdContext(cmd.Context()).WithViper(EnvPrefix)
clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags()) clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags())
if err != nil { if err != nil {
return err return err
@ -96,10 +96,6 @@ func NewRootCmd() *cobra.Command {
return err return err
} }
if err := client.SetCmdClientContextHandler(clientCtx, cmd); err != nil {
return err
}
// overwrite the minimum gas price from the app configuration // overwrite the minimum gas price from the app configuration
srvCfg := serverconfig.DefaultConfig() srvCfg := serverconfig.DefaultConfig()
srvCfg.MinGasPrices = "0photon" srvCfg.MinGasPrices = "0photon"
@ -138,7 +134,9 @@ func ProvideClientContext(
WithLegacyAmino(legacyAmino). WithLegacyAmino(legacyAmino).
WithInput(os.Stdin). WithInput(os.Stdin).
WithAccountRetriever(types.AccountRetriever{}). WithAccountRetriever(types.AccountRetriever{}).
WithHomeDir(app.DefaultNodeHome). // Workaround: Avoid providing DefaultNodeHome to depinject as it is given precedence over the one passed using --home flag in some CLI commands
// TODO: Implement proper fix
// WithHomeDir(app.DefaultNodeHome).
WithViper(EnvPrefix) // env variable prefix WithViper(EnvPrefix) // env variable prefix
// Read the config again to overwrite the default values with the values from the config file // Read the config again to overwrite the default values with the values from the config file