1package main
2
3import (
4	"errors"
5)
6
7// CmdCurrent is `direnv current`
8var CmdCurrent = &Cmd{
9	Name:    "current",
10	Desc:    "Reports whether direnv's view of a file is current (or stale)",
11	Args:    []string{"PATH"},
12	Private: true,
13	Action:  actionSimple(cmdCurrentAction),
14}
15
16func cmdCurrentAction(env Env, args []string) (err error) {
17	if len(args) < 2 {
18		err = errors.New("missing PATH argument")
19		return
20	}
21
22	path := args[1]
23	watches := NewFileTimes()
24	watchString, ok := env[DIRENV_WATCHES]
25	if ok {
26		err = watches.Unmarshal(watchString)
27		if err != nil {
28			return
29		}
30	}
31
32	err = watches.CheckOne(path)
33
34	return
35}
36