-
Notifications
You must be signed in to change notification settings - Fork 2
/
cmd.go
57 lines (45 loc) · 1.64 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
55
56
57
package cli
import (
"fmt"
"github.com/spf13/cobra"
)
func (cli *CLI) buildRootCmd() {
if cli.rootCmd != nil {
cli.rootCmd.ResetFlags()
cli.rootCmd.ResetCommands()
}
rootCmd := &cobra.Command{
Use: "NewChainBlind",
Short: "NewChainBlind is a commandline client for the NewChain",
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, "NewChain json rpc or ipc `url`")
// Basic commands
rootCmd.AddCommand(cli.buildVersionCmd()) // version
rootCmd.AddCommand(cli.buildInitCmd()) // init
// Aux commands
rootCmd.AddCommand(cli.buildBalanceCmd()) // balance
rootCmd.AddCommand(cli.buildFaucetCmd()) // faucet
// Alias commands
rootCmd.AddCommand(cli.buildAccountCmd()) // account
// Core commands
rootCmd.AddCommand(cli.buildInfoCmd()) // bank info
rootCmd.AddCommand(cli.buildDepositCmd()) // deposit NEW by hash
rootCmd.AddCommand(cli.buildSignCmd()) // bank sign
rootCmd.AddCommand(cli.buildVerifyCmd()) // bank verify
rootCmd.AddCommand(cli.buildBlindCmd()) // customer blind
rootCmd.AddCommand(cli.buildUnblindCmd()) // customer unblind
}
func EmptyRun(cmd *cobra.Command, args []string) {
if err := cobra.OnlyValidArgs(cmd, args); err != nil {
fmt.Println(err)
fmt.Printf("Run '%v --help' for usage.\n", cmd.CommandPath())
return
}
fmt.Println(cmd.UsageString())
}