-
Notifications
You must be signed in to change notification settings - Fork 232
/
config.go
44 lines (34 loc) · 1.07 KB
/
config.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
package main
import (
"path/filepath"
"github.com/jessevdk/go-flags"
"github.com/kaspanet/kaspad/stability-tests/common"
)
const (
defaultLogFilename = "netsync.log"
defaultErrLogFilename = "netsync_err.log"
)
var (
// Default configuration options
defaultLogFile = filepath.Join(common.DefaultAppDir, defaultLogFilename)
defaultErrLogFile = filepath.Join(common.DefaultAppDir, defaultErrLogFilename)
)
type configFlags struct {
LogLevel string `short:"d" long:"loglevel" description:"Set log level {trace, debug, info, warn, error, critical}"`
NumberOfBlocks uint64 `short:"n" long:"numblocks" description:"Number of blocks to mine" required:"true"`
TargetFile string `short:"f" long:"targetfile" description:"The target file for the JSON" required:"true"`
}
var cfg *configFlags
func activeConfig() *configFlags {
return cfg
}
func parseConfig() error {
cfg = &configFlags{}
parser := flags.NewParser(cfg, flags.PrintErrors|flags.HelpFlag)
_, err := parser.Parse()
if err != nil {
return err
}
initLog(defaultLogFile, defaultErrLogFile)
return nil
}