/
main.go
127 lines (107 loc) · 2.67 KB
/
main.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package main
import (
"github.com/QOSGroup/qstars/star"
"github.com/QOSGroup/qstars/x/jianqian/buyad"
"github.com/QOSGroup/qstars/x/jianqian/investad"
"github.com/QOSGroup/qstars/x/jianqian/article"
"github.com/QOSGroup/qstars/x/jianqian/coins"
qbasecli "github.com/QOSGroup/qbase/client"
"os"
"github.com/QOSGroup/qbase/version"
"github.com/QOSGroup/qstars/client"
"github.com/QOSGroup/qstars/client/lcd"
"github.com/QOSGroup/qstars/config"
authcmd "github.com/QOSGroup/qstars/x/auth"
bankcmd "github.com/QOSGroup/qstars/x/bank"
"github.com/QOSGroup/qstars/x/kvstore"
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/libs/cli"
)
// rootCmd is the entry point for this binary
var (
rootCmd = &cobra.Command{
Use: "basecli",
Short: "Basecoin light-client",
}
)
func main() {
// disable sorting
cobra.EnableCommandSorting = false
// get the codec
cdc := star.MakeCodec()
rootCmd := &cobra.Command{
Use: "cmd",
Short: "qstars Command Line Interface(command)",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Name() == version.VersionCmd.Name() {
return nil
}
cfg, err := config.InterceptLoadConfig()
if err != nil {
return err
}
config.CreateCLIContextTwo(cdc, cfg)
return nil
},
}
// TODO: Setup keybase, viper object, etc. to be passed into
// the below functions and eliminate global vars, like we do
// with the cdc.
// add query/post commands (custom to binary)
rootCmd.AddCommand(
client.GetCommands(
authcmd.GetAccountCmd(cdc),
authcmd.CreateAccountCmd(cdc),
)...)
//
rootCmd.AddCommand(
client.PostCommands(
bankcmd.SendTxCmd(cdc),
bankcmd.ApproveCmd(cdc),
)...)
//
rootCmd.AddCommand(
client.PostCommands(
kvstore.SendKVCmd(cdc),
kvstore.GetKVCmd(cdc),
)...)
//
rootCmd.AddCommand(
client.PostCommands(
coins.DispatchAOECmd(cdc),
article.NewArticleCmd(cdc),
article.QueryArticleCmd(cdc),
coins.QueryCoinsCmd(cdc),
)...)
// add proxy, version and key info
rootCmd.AddCommand(
client.LineBreak,
lcd.ServeCommand(cdc),
// keys.Commands(),
// client.LineBreak,
// version.VersionCmd,
)
rootCmd.AddCommand(
buyad.BuyadCmd(cdc),
investad.InvestadCmd(cdc),
)
// add commands provided by qbase
qbaseCmd := &cobra.Command{
Use: "qbase",
Short: "qbase commands",
}
qbaseCmd.AddCommand(
qbasecli.QueryCommand(cdc),
qbasecli.KeysCommand(cdc),
qbasecli.TendermintCommand(cdc),
qbasecli.TxCommand(),
)
rootCmd.AddCommand(qbaseCmd)
// prepare and add flags
executor := cli.PrepareBaseCmd(rootCmd, "BC", os.ExpandEnv("$HOME/.qstarscli"))
err := executor.Execute()
if err != nil {
// Note: Handle with #870
panic(err)
}
}