Skip to content

Commit

Permalink
fix(cli): home flag gets ignored when running help (cosmos#11645)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Apr 21, 2022
1 parent 11596bb commit 310319b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions 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 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

0 comments on commit 310319b

Please sign in to comment.