-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathargs.go
42 lines (35 loc) · 757 Bytes
/
args.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
package monerotipbot
import (
"flag"
"fmt"
"log"
)
// ParseArguments parses all CLI arguments
func ParseArguments() (*Config, error) {
// Did the user ask for help?
parseErr := fmt.Errorf("")
var (
configpath string
debug bool
nolog bool
)
flag.StringVar(&configpath, "c", "", "")
flag.BoolVar(&debug, "debug", false, "")
flag.Parse()
if !flag.Parsed() {
return nil, parseErr
}
// Validate arguments and save configuration
config, err := saveConfig(configpath, debug, nolog)
if err != nil {
log.Println(err)
return nil, err
}
return config, nil
}
func saveConfig(configpath string, debug, nolog bool) (*Config, error) {
conf := NewConfig()
conf.SetConfig(configpath)
conf.SetDebug(debug)
return conf, nil
}