This repository has been archived by the owner on Mar 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpkgCmds.go
96 lines (77 loc) · 2.29 KB
/
pkgCmds.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package main
import "runtime"
func getInstCmd(pkg Package) []string {
log(1, "Getting install commands...")
var cmds []string
if pkg.Commands == nil {
return []string{}
}
if pkg.Commands.All != nil && pkg.Commands.All.Install != nil {
cmds = pkg.Commands.All.Install
}
switch runtime.GOOS {
case "darwin":
if pkg.Commands.Darwin != nil && pkg.Commands.Darwin.Install != nil {
debugLog("Getting install commands for Darwin. Package: %s", bolden(pkg.Name))
cmds = pkg.Commands.Darwin.Install
}
case "linux":
if pkg.Commands.Linux != nil && pkg.Commands.Linux.Install != nil {
debugLog("Getting install commands for Linux. Package: %s", bolden(pkg.Name))
cmds = pkg.Commands.Linux.Install
}
default:
log(3, "Unknown OS: %s", runtime.GOOS)
}
return cmds
}
func getUninstCmd(pkg Package) []string {
log(1, "Getting uninstall commands...")
var cmds []string
if pkg.Commands == nil {
return []string{}
}
if pkg.Commands.All != nil && pkg.Commands.All.Uninstall != nil {
cmds = pkg.Commands.All.Uninstall
}
switch runtime.GOOS {
case "darwin":
if pkg.Commands.Darwin != nil && pkg.Commands.Darwin.Uninstall != nil {
debugLog("Getting uninstall commands for Darwin. Package: %s", bolden(pkg.Name))
cmds = pkg.Commands.Darwin.Uninstall
}
case "linux":
if pkg.Commands.Linux != nil && pkg.Commands.Linux.Uninstall != nil {
debugLog("Getting uninstall commands for Linux. Package: %s", bolden(pkg.Name))
cmds = pkg.Commands.Linux.Uninstall
}
default:
log(3, "Unknown OS: %s", runtime.GOOS)
}
return cmds
}
func getUpdCmd(pkg Package) []string {
log(1, "Getting upgrade commands...")
var cmds []string
if pkg.Commands == nil {
return []string{}
}
if pkg.Commands.All != nil && pkg.Commands.All.Update != nil {
cmds = pkg.Commands.All.Update
}
switch runtime.GOOS {
case "darwin":
if pkg.Commands.Darwin != nil && pkg.Commands.Darwin.Update != nil {
debugLog("Getting update commands for Darwin. Package: %s", bolden(pkg.Name))
cmds = pkg.Commands.Darwin.Update
}
case "linux":
if pkg.Commands.Linux != nil && pkg.Commands.Linux.Update != nil {
debugLog("Getting update commands for Linux. Package: %s", bolden(pkg.Name))
cmds = pkg.Commands.Linux.Update
}
default:
log(3, "Unknown OS: %s", runtime.GOOS)
}
return cmds
}