-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobals.go
73 lines (64 loc) · 1.71 KB
/
globals.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
package sh
import (
"fmt"
"os"
"github.com/zdz1715/go-sh/shell"
)
var gExecOptions = &ExecOptions{
IDCreator: XidCreator,
Shell: &shell.Shell{
Type: shell.Bash,
Set: shell.EXPipeFail,
},
Storage: &Storage{
Dir: "",
NotAutoClean: false,
},
User: "",
WorkDir: "",
Output: func(num int, line []byte) {
fmt.Fprintln(os.Stderr, bytesToString(line))
},
}
// SetGlobalExecWorkDir Sets the working directory for execution globally.
// If the working directory has been set separately,
// it will not be overwritten.
func SetGlobalExecWorkDir(dir string) {
gExecOptions.WorkDir = dir
}
// SetGlobalExecUser Sets the user for execution globally.
// If the user has been set separately,
// it will not be overwritten.
func SetGlobalExecUser(user string) {
gExecOptions.User = user
}
// SetGlobalExecOutput Sets the output func for execution globally.
// If the output func has been set separately,
// it will not be overwritten.
func SetGlobalExecOutput(f func(num int, line []byte)) {
gExecOptions.Output = f
}
// SetGlobalStorage Sets the storage for execution globally.
// If the storage has been set separately,
// it will not be overwritten.
func SetGlobalStorage(storage *Storage) {
gExecOptions.Storage = storage
}
// SetGlobalIDCreator Sets the ID Creator for execution globally.
// If the ID Creator has been set separately,
// it will not be overwritten.
func SetGlobalIDCreator(creator IDCreator) {
if creator == nil {
return
}
gExecOptions.IDCreator = creator
}
// SetGlobalShell Sets the shell for execution globally.
// If the shell has been set separately,
// it will not be overwritten.
func SetGlobalShell(shell *shell.Shell) {
if shell == nil {
return
}
gExecOptions.Shell = shell
}