-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.go
More file actions
46 lines (39 loc) · 690 Bytes
/
main.go
File metadata and controls
46 lines (39 loc) · 690 Bytes
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
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"github.com/JayceChant/commit-msg/validator"
)
var (
versionFlag = flag.Bool("version", false, "")
version string
goVersion string
commitHash string
buildTime string
)
func main() {
flag.Parse()
if *versionFlag {
printVersion(os.Args[0])
return
}
msgFile := ""
if len(os.Args) > 1 {
msgFile = os.Args[1]
}
validator.Validate(msgFile)
}
func printVersion(cmd string) {
fmt.Println(filepath.Base(cmd), version)
if goVersion != "" {
fmt.Println(goVersion)
}
if commitHash != "" {
fmt.Println("commit hash :", commitHash)
}
if buildTime != "" {
fmt.Println("build at :", buildTime)
}
}