camtool: add env camsrcroot

Change-Id: I701e81ab732d7574a227e8f01ca09ac91c608481
This commit is contained in:
Brad Fitzpatrick 2014-01-31 12:21:04 +01:00
parent 63d4bafd0c
commit bda047eef7
1 changed files with 11 additions and 0 deletions

View File

@ -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 ""
}