Skip to content

Commit

Permalink
feat: extend debug cmd adding decode-blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Apr 12, 2022
1 parent 1749e70 commit 2959444
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cmd/okp4d/main.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package main

import (
"fmt"
"os"

svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/okp4/okp4d/app"
"github.com/spf13/cobra"
"github.com/tendermint/starport/starport/pkg/cosmoscmd"
)

Expand All @@ -18,7 +20,30 @@ func main() {
app.New,
// this line is used by starport scaffolding # root/arguments
)

if err := Extend(rootCmd); err != nil {
os.Exit(1)
}

if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil {
os.Exit(1)
}
}

func Extend(cmd *cobra.Command) error {
cmdGetter := func(name string) (*cobra.Command, error) {
return getSubCommand(cmd, name)
}

return ExtendDebugCmd(cmdGetter)
}

func getSubCommand(cmd *cobra.Command, name string) (*cobra.Command, error) {
for i, v := range cmd.Commands() {
if v.Name() == name {
return cmd.Commands()[i], nil
}
}

return nil, fmt.Errorf("cannot find '%s' command", name)
}

0 comments on commit 2959444

Please sign in to comment.