patch keys parse command (#700)

This commit is contained in:
Kevin Davis 2020-11-13 17:29:30 -05:00 committed by GitHub
parent e1ad9569a7
commit 9472c09b91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,12 +46,25 @@ func getModifiedKeysCmd() *cobra.Command {
for _, c := range keysCmd.Commands() {
if c.Name() == "add" {
monkeyPatchCmdKeysAdd(c)
break
}
if c.Name() == "parse" {
monkeyPatchCmdKeysParse(c)
}
}
return keysCmd
}
func monkeyPatchCmdKeysParse(keysParseCmd *cobra.Command) {
// replace the run function with a wrapped version that sets the old coin type in the global config
oldRun := keysParseCmd.RunE
keysParseCmd.RunE = func(cmd *cobra.Command, args []string) error {
sdk.GetConfig().Seal()
return oldRun(cmd, args)
}
}
// monkeyPatchCmdKeysAdd modifies the `keys add` command to use the old bip44 coin type when a flag is passed.
func monkeyPatchCmdKeysAdd(keysAddCmd *cobra.Command) {
// add flag