Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions client/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 {
Expand Down
19 changes: 19 additions & 0 deletions simapp/simd/cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}
4 changes: 2 additions & 2 deletions simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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,
}
Expand Down