-
Notifications
You must be signed in to change notification settings - Fork 5
/
dcrm_flags.go
72 lines (61 loc) · 1.67 KB
/
dcrm_flags.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
// Copyright 2018 The fusion-dcrm
//Author: caihaijun@fusion.org
package utils
import (
"path/filepath"
"github.com/fusion/go-fusion/node"
"gopkg.in/urfave/cli.v1"
)
var (
VersionEnabledFlag = cli.BoolFlag{
Name: "v",
Usage: "show build version.",
}
)
func ShowVer(ctx *cli.Context) bool {
if ctx.GlobalBool(VersionEnabledFlag.Name) {
return true
}
return false
}
func SetDcrmNodeConfig(ctx *cli.Context, cfg *node.Config) {
SetP2PConfig(ctx, &cfg.P2P)
setIPC(ctx, cfg)
setHTTP(ctx, cfg)
setWS(ctx, cfg)
setNodeUserIdent(ctx, cfg)
switch {
case ctx.GlobalIsSet(DataDirFlag.Name):
cfg.DataDir = ctx.GlobalString(DataDirFlag.Name)
case ctx.GlobalBool(DeveloperFlag.Name):
cfg.DataDir = "" // unless explicitly requested, use memory databases
case ctx.GlobalBool(TestnetFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet")
case ctx.GlobalBool(RinkebyFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby")
}
cfg.DataDir = "" //tmp
if ctx.GlobalIsSet(KeyStoreDirFlag.Name) {
cfg.KeyStoreDir = ctx.GlobalString(KeyStoreDirFlag.Name)
}
if ctx.GlobalIsSet(LightKDFFlag.Name) {
cfg.UseLightweightKDF = ctx.GlobalBool(LightKDFFlag.Name)
}
if ctx.GlobalIsSet(NoUSBFlag.Name) {
cfg.NoUSB = ctx.GlobalBool(NoUSBFlag.Name)
}
}
// NewFusionDcrmApp creates an app with sane defaults.
func NewFusionDcrmApp(gitCommit, usage string) *cli.App {
app := cli.NewApp()
app.Name = "FusionDcrm"//filepath.Base(os.Args[0])
app.Author = "caihaijun"
//app.Authors = nil
app.Email = "caihaijun@fusion.org"
app.Version = "3.0.5"
if len(gitCommit) >= 8 {
app.Version += "-" + gitCommit[:8]
}
app.Usage = usage
return app
}