forked from direnv/direnv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd_status.go
50 lines (41 loc) · 1.19 KB
/
cmd_status.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
package main
import (
"fmt"
"path/filepath"
)
// CmdStatus is `direnv status`
var CmdStatus = &Cmd{
Name: "status",
Desc: "prints some debug status information",
Action: actionWithConfig(func(env Env, args []string, config *Config) error {
fmt.Println("direnv exec path", config.SelfPath)
fmt.Println("DIRENV_CONFIG", config.ConfDir)
fmt.Println("bash_path", config.BashPath)
fmt.Println("disable_stdin", config.DisableStdin)
fmt.Println("warn_timeout", config.WarnTimeout)
fmt.Println("whitelist.prefix", config.WhitelistPrefix)
fmt.Println("whitelist.exact", config.WhitelistExact)
loadedRC := config.LoadedRC()
foundRC := config.FindRC()
if loadedRC != nil {
formatRC("Loaded", loadedRC)
} else {
fmt.Println("No .envrc loaded")
}
if foundRC != nil {
formatRC("Found", foundRC)
} else {
fmt.Println("No .envrc found")
}
return nil
}),
}
func formatRC(desc string, rc *RC) {
workDir := filepath.Dir(rc.path)
fmt.Println(desc, "RC path", rc.path)
for idx := range *(rc.times.list) {
fmt.Println(desc, "watch:", (*rc.times.list)[idx].Formatted(workDir))
}
fmt.Println(desc, "RC allowed", rc.Allowed())
fmt.Println(desc, "RC allowPath", rc.allowPath)
}