From bda047eef7cf012e36820070ab8f8e9fa7b04612 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 31 Jan 2014 12:21:04 +0100 Subject: [PATCH] camtool: add env camsrcroot Change-Id: I701e81ab732d7574a227e8f01ca09ac91c608481 --- cmd/camtool/env.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/camtool/env.go b/cmd/camtool/env.go index 7ec06afc8..dc5e015e9 100644 --- a/cmd/camtool/env.go +++ b/cmd/camtool/env.go @@ -20,6 +20,7 @@ import ( "flag" "fmt" "os" + "path/filepath" "camlistore.org/pkg/cmdmain" "camlistore.org/pkg/osutil" @@ -29,6 +30,7 @@ var envMap = map[string]func() string{ "configdir": osutil.CamliConfigDir, "clientconfig": osutil.UserClientConfigPath, "serverconfig": osutil.UserServerConfigPath, + "camsrcroot": srcRoot, } type envCmd struct{} @@ -64,3 +66,12 @@ func (c *envCmd) RunCommand(args []string) error { fmt.Println(fn()) return nil } + +func srcRoot() string { + for _, dir := range filepath.SplitList(os.Getenv("GOPATH")) { + if d := filepath.Join(dir, "src", "camlistore.org"); osutil.DirExists(d) { + return d + } + } + return "" +}