-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
56 lines (47 loc) · 1017 Bytes
/
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
45
46
47
48
49
50
51
52
53
54
55
56
package extract
import (
"flag"
"gopkg.in/src-d/go-git.v4/plumbing"
"os"
"path/filepath"
)
type HashOptions struct {
From plumbing.Hash
To plumbing.Hash
}
type ConfigOptions struct {
TargetDir string
Debug bool
Hash *HashOptions
}
var Config *ConfigOptions
func init() {
var from, to, targetDir string
var debug bool
flag.StringVar(&from, "from", "", "git log begin hash")
flag.StringVar(&to, "to", "", "git log end hash")
flag.StringVar(&targetDir, "out", getExecutePath(), "git change output dir")
flag.BoolVar(&debug, "debug", true, "open debug log")
flag.Parse()
var fromHash plumbing.Hash
if from != "" {
fromHash = plumbing.NewHash(from)
}
var toHash plumbing.Hash
if to != "" {
toHash = plumbing.NewHash(to)
}
Config = &ConfigOptions{
TargetDir: targetDir,
Debug: debug,
Hash: &HashOptions{
From: fromHash,
To: toHash,
},
}
}
func getExecutePath() string {
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
CheckIfError(err)
return dir
}