From 50d9bceec71fb562aee73911ac56d6545335e85b Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 4 Oct 2018 12:31:48 +0200 Subject: [PATCH] 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) --- cmd/aicra/main.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cmd/aicra/main.go b/cmd/aicra/main.go index 02d42b6..dbd5390 100644 --- a/cmd/aicra/main.go +++ b/cmd/aicra/main.go @@ -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 */