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
|
package main
import (
"errors"
)
// CmdCurrent is `direnv current`
var CmdCurrent = &Cmd{
Name: "current",
Desc: "Reports whether direnv's view of a file is current (or stale)",
Args: []string{"PATH"},
Private: true,
Action: actionSimple(cmdCurrentAction),
}
func cmdCurrentAction(env Env, args []string) (err error) {
if len(args) < 2 {
err = errors.New("missing PATH argument")
return
}
path := args[1]
watches := NewFileTimes()
watchString, ok := env[DIRENV_WATCHES]
if ok {
err = watches.Unmarshal(watchString)
if err != nil {
return
}
}
err = watches.CheckOne(path)
return
}
|