-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (53 loc) · 1.19 KB
/
main.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
package main
import (
"fmt"
"os"
"time"
"tversion/utils"
"tversion/version"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("用法", "tver commit|versions|checkout")
os.Exit(1)
}
if os.Args[1] != "checkout" && os.Args[1] != "commit" && os.Args[1] != "versions" {
fmt.Println("用法", "tver commit|versions|checkout")
os.Exit(1)
}
if os.Args[1] == "checkout" && len(os.Args) < 3 {
fmt.Println("必须输入要checkout到的版本")
os.Exit(1)
}
action := os.Args[1]
versionNum := ""
if os.Args[1] == "checkout" {
versionNum = os.Args[2]
}
start := time.Now()
if action == "commit" {
version.Commit(utils.GetWd(), utils.Tmd5())
elapsed := time.Since(start)
fmt.Printf("执行时长 %s", elapsed)
os.Exit(0)
}
if action == "versions" {
if len(os.Args) < 3 {
version.ShowVersions()
elapsed := time.Since(start)
fmt.Printf("执行时长 %s", elapsed)
os.Exit(0)
} else {
version.ShowFileVersion(os.Args[2])
elapsed := time.Since(start)
fmt.Printf("执行时长 %s", elapsed)
os.Exit(0)
}
}
if action == "checkout" {
version.Checkout(versionNum)
elapsed := time.Since(start)
fmt.Printf("执行时长 %s", elapsed)
os.Exit(0)
}
}