-
Notifications
You must be signed in to change notification settings - Fork 2
/
cmd.go
35 lines (28 loc) · 989 Bytes
/
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
package cli
import (
"github.com/spf13/cobra"
)
func (cli *CLI) buildRootCmd() {
if cli.rootCmd != nil {
cli.rootCmd.ResetFlags()
cli.rootCmd.ResetCommands()
}
rootCmd := &cobra.Command{
Use: cli.name,
Short: cli.name + " a server program that can get free money",
Run: cli.help,
PersistentPreRun: cli.setup,
}
cli.rootCmd = rootCmd
// Global flags
rootCmd.PersistentFlags().StringVarP(&cli.config, "config", "c", defaultConfigFile, "The `path` to config file")
rootCmd.PersistentFlags().StringP("walletPath", "w", defaultWalletPath, "Wallet storage `directory`")
rootCmd.PersistentFlags().StringP("rpcURL", "i", defaultRPCURL, "Geth json rpc or ipc `url`")
// Basic commands
rootCmd.AddCommand(cli.buildVersionCmd()) // version
rootCmd.AddCommand(cli.buildInitCmd()) // init
// Core commands
rootCmd.AddCommand(cli.buildStartCmd()) // pay
// Alias commands
rootCmd.AddCommand(cli.buildAccountCmd()) // account
}