fix(cli): home flag gets ignored when running help (#11645)

This commit is contained in:
Julien Robert 2022-04-21 15:27:31 +02:00 committed by GitHub
parent 2f6a3e6b05
commit 2c94c2e1b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 2 deletions

View File

@ -211,6 +211,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes
* [\#11693](https://github.com/cosmos/cosmos-sdk/pull/11693) Add validation for gentx cmd.
* [\#11645](https://github.com/cosmos/cosmos-sdk/pull/11645) Fix `--home` flag ignored when running help.
* [\#11558](https://github.com/cosmos/cosmos-sdk/pull/11558) Fix `--dry-run` not working when using tx command.
* [\#11354](https://github.com/cosmos/cosmos-sdk/pull/11355) Added missing pagination flag for `bank q total` query.
* [\#11197](https://github.com/cosmos/cosmos-sdk/pull/11197) Signing with multisig now works with multisig address which is not in the keyring.

View File

@ -70,6 +70,7 @@ func TestSetCmdClientContextHandler(t *testing.T) {
}
c.Flags().String(flags.FlagChainID, "", "network chain ID")
c.Flags().String(flags.FlagHome, "", "home dir")
return c
}
@ -91,6 +92,14 @@ func TestSetCmdClientContextHandler(t *testing.T) {
fmt.Sprintf("--%s=new-chain-id", flags.FlagChainID),
},
},
{
"flags set with space",
initClientCtx.WithHomeDir("/tmp/dir"),
[]string{
fmt.Sprintf("--%s", flags.FlagHome),
"/tmp/dir",
},
},
}
for _, tc := range testCases {

View File

@ -6,6 +6,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/client/flags"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/simapp/simd/cmd"
@ -22,3 +23,21 @@ func TestInitCmd(t *testing.T) {
require.NoError(t, svrcmd.Execute(rootCmd, "", simapp.DefaultNodeHome))
}
func TestHomeFlagRegistration(t *testing.T) {
homeDir := "/tmp/foo"
rootCmd, _ := cmd.NewRootCmd()
rootCmd.SetArgs([]string{
"query",
fmt.Sprintf("--%s", flags.FlagHome),
homeDir,
})
require.NoError(t, svrcmd.Execute(rootCmd, "", simapp.DefaultNodeHome))
result, err := rootCmd.Flags().GetString(flags.FlagHome)
require.NoError(t, err)
require.Equal(t, result, homeDir)
}

View File

@ -192,7 +192,7 @@ func queryCommand() *cobra.Command {
Use: "query",
Aliases: []string{"q"},
Short: "Querying subcommands",
DisableFlagParsing: true,
DisableFlagParsing: false,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
@ -215,7 +215,7 @@ func txCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "tx",
Short: "Transactions subcommands",
DisableFlagParsing: true,
DisableFlagParsing: false,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}