/
cmd.go
54 lines (43 loc) · 1.59 KB
/
cmd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Package cmd contains cli wrapper for the onomy cli.
package cmd
import (
"fmt"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"
"github.com/tendermint/starport/starport/pkg/cosmoscmd"
"github.com/tendermint/tendermint/libs/cli"
"github.com/onomyprotocol/onomy/app"
)
// NewRootCmd initiates the cli for onomy chain.
func NewRootCmd() (*cobra.Command, cosmoscmd.EncodingConfig) {
rootCmd, encodingConfig := cosmoscmd.NewRootCmd(
app.Name,
app.AccountAddressPrefix,
app.DefaultNodeHome,
app.Name,
app.ModuleBasics,
app.New,
)
rootCmd.AddCommand(
server.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Marshaler),
)
return rootCmd, encodingConfig
}
// WrapBridgeCommands registers a sub-tree of gravity commands.
func WrapBridgeCommands(defaultNodeHome, rootCmd string, cmds []*cobra.Command) *cobra.Command {
//nolint: exhaustivestruct
cmd := &cobra.Command{
Use: rootCmd,
Short: fmt.Sprintf("Manage %s bridge.", rootCmd),
Long: fmt.Sprintf("Manage %s bridge.", rootCmd),
}
for _, childCmd := range cmds {
cmd.AddCommand(childCmd)
}
cmd.PersistentFlags().String(flags.FlagHome, defaultNodeHome, "The application home directory")
cmd.PersistentFlags().String(flags.FlagKeyringDir, "", "The client Keyring directory; if omitted, the default 'home' directory will be used")
cmd.PersistentFlags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)")
cmd.PersistentFlags().String(cli.OutputFlag, "text", "Output format (text|json)")
return cmd
}