-
Notifications
You must be signed in to change notification settings - Fork 8
/
path.go
77 lines (66 loc) · 1.38 KB
/
path.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
package main
import (
"path/filepath"
"strconv"
"strings"
)
func get_luacpath() string {
prefix := filepath.Clean(CurrentDir+"/lua_modules/luaclib") + "/"
paths := []string{}
for i := 0; i <= 10; i++ {
dir := prefix + strconv.Itoa(i)
paths = append(paths, dir+"/?.so")
}
return strings.Join(paths, ";") + ";;"
}
func get_luapath() string {
prefix := filepath.Clean(CurrentDir+"/lua_modules/lualib") + "/"
paths := []string{}
for i := 0; i <= 10; i++ {
dir := prefix + strconv.Itoa(i)
paths = append(paths, dir+"/?.lua", dir+"/?/init.lua")
}
return strings.Join(paths, ";") + ";;"
}
func get_path() string {
return strings.Join([]string{
filepath.Clean(CurrentDir + "/bin"),
filepath.Clean(CurrentDir + "/lua_modules/bin"),
}, ":")
}
func printAll() {
printf(`
#
# please add the following lenv settings to your environment
#
`)
for _, name := range []string{"PATH", "LUA_PATH", "LUA_CPATH"} {
var value string
switch name {
case "PATH":
value = get_path() + ":$PATH"
case "LUA_PATH":
value = get_luapath()
case "LUA_CPATH":
value = get_luacpath()
}
printf(`export %s="%s"`, name, value)
}
printf("")
}
func CmdPath(opts []string) {
if len(opts) > 0 {
switch opts[0] {
case "bin":
printf(get_path())
return
case "lualib":
printf(get_luapath())
return
case "luaclib":
printf(get_luacpath())
return
}
}
printAll()
}