-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_std.go
79 lines (62 loc) · 1.55 KB
/
cmd_std.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package gitw
// debug for std
var debug bool
var std = newStd()
// IsDebug mode
func IsDebug() bool {
return debug
}
// SetDebug mode
func SetDebug(open bool) {
debug = open
if open {
std.BeforeExec = PrintCmdline
} else {
std.BeforeExec = nil
}
}
// Std instance get
func Std() *GitWrap { return std }
// RestStd instance
func RestStd() {
std = newStd()
}
// GlobalFlags for run git command
var GlobalFlags []string
func gitCmd(args ...string) *GitWrap {
// with global flags
return std.New(GlobalFlags...).WithArgs(args)
}
func cmdWithArgs(subCmd string, args ...string) *GitWrap {
// with global flags
return std.Cmd(subCmd, GlobalFlags...).WithArgs(args)
}
func newStd() *GitWrap {
gw := New()
// load debug setting.
debug = isDebugFromEnv()
if debug {
gw.BeforeExec = PrintCmdline
}
return gw
}
// -------------------------------------------------
// git commands use std
// -------------------------------------------------
// Branch command of git
func Branch(args ...string) *GitWrap { return std.Branch(args...) }
// Log command of git
//
// Usage: Log("-2").OutputLines()
func Log(args ...string) *GitWrap { return std.Log(args...) }
// RevList command of git
func RevList(args ...string) *GitWrap { return std.RevList(args...) }
// Remote command of git
func Remote(args ...string) *GitWrap { return std.Remote(args...) }
// Show command of git
func Show(args ...string) *GitWrap { return std.Show(args...) }
// Tag command of git
//
// Usage:
// Tag("-l").OutputLines()
func Tag(args ...string) *GitWrap { return std.Tag(args...) }