-
Notifications
You must be signed in to change notification settings - Fork 11
/
sgnops.go
70 lines (62 loc) · 1.8 KB
/
sgnops.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
package cmd
import (
"os"
"path/filepath"
"github.com/celer-network/goutils/log"
"github.com/celer-network/sgn/app"
"github.com/celer-network/sgn/common"
"github.com/celer-network/sgn/ops"
"github.com/celer-network/sgn/testing/channel"
tc "github.com/celer-network/sgn/testing/common"
"github.com/celer-network/sgn/transactor"
"github.com/cosmos/cosmos-sdk/version"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tendermint/tendermint/libs/cli"
)
func GetSgnopsExecutor() cli.Executor {
cdc := app.MakeCodec()
rootCmd := &cobra.Command{
Use: "sgnops",
Short: "sgn ops utility",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
sgnConfigPath := viper.GetString(common.FlagConfig)
_, err := os.Stat(sgnConfigPath)
if err != nil {
return err
}
viper.SetConfigFile(sgnConfigPath)
err = viper.ReadInConfig()
if err != nil {
return err
}
log.SetLevelByName(viper.GetString(common.FlagLogLevel))
if viper.GetBool(common.FlagLogColor) {
log.EnableColor()
}
return common.SetupUserPassword()
},
}
rootCmd.AddCommand(
transactor.AccountsCommand(),
ops.SnapshotMainchainCommand(),
ops.InitCandidateCommand(),
ops.DelegateCommand(),
ops.WithdrawCommand(cdc),
ops.ClaimValidatorCommand(),
ops.ConfirmUnbondedCandidateCommand(),
ops.UpdateMinSelfStakeCommand(),
ops.UpdateCommissionRateCommand(),
ops.GetCandidateInfoCommand(),
ops.GetDelegatorInfoCommand(),
ops.GetAllValidatorsCommand(),
ops.GetSyncCmd(cdc),
ops.GovCommand(),
tc.DeployCommand(),
channel.GuardTestCommand(),
version.Cmd,
)
rootCmd.PersistentFlags().String(
common.FlagConfig, filepath.Join(app.DefaultCLIHome, "config", "sgn.toml"), "Path to SGN-specific configs")
return cli.PrepareMainCmd(rootCmd, "SGN", app.DefaultCLIHome)
}