update 'aicra' command now chdir to first argument (to find the aicra.json conf and to have a valid relative path from its 'root' field)

This commit is contained in:
Adrien Marquès 2018-10-04 12:31:48 +02:00
parent 0053f475e2
commit 50d9bceec7
1 changed files with 18 additions and 0 deletions

View File

@ -13,6 +13,24 @@ var defaultTypeFolder = filepath.Join(os.Getenv("GOPATH"), "src/git.xdrm.io/go/a
func main() {
// check argument
if len(os.Args) < 2 || len(os.Args[1]) < 1 {
fmt.Printf("missing argument: project path\n")
return
}
// get absolute path from arguments
root := os.Args[1]
rootStat, err := os.Stat(root)
if err != nil || !rootStat.IsDir() {
fmt.Printf("invalid argument: project path is invalid or not a directory\n")
return
}
if err := os.Chdir(root); err != nil {
fmt.Printf("invalid argument: cannot chdir to %s\n", root)
return
}
starttime := time.Now()
/* 1. Load config */