From d9460952abe8bc9a285f6c328aa0b71248d9146b Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 7 Jul 2018 12:58:46 +0200 Subject: [PATCH] add formatting + check which (controllers, types) to compile --- cmd/aicra/main.go | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/cmd/aicra/main.go b/cmd/aicra/main.go index 8dafb96..d1745bc 100644 --- a/cmd/aicra/main.go +++ b/cmd/aicra/main.go @@ -27,6 +27,8 @@ func main() { return } var projectPathFlag = flag.Arg(0) + compileTypes := true + compileControllers := true /* (2) Get absolute paths ---------------------------------------------------------*/ @@ -58,28 +60,41 @@ func main() { /* (3) Check path are existing dirs ---------------------------------------------------------*/ + clifmt.Title("Check files") + /* (1) Project path */ + clifmt.Align(" . project root") if stat, err := os.Stat(projectPath); err != nil || !stat.IsDir() { + fmt.Printf("invalid\n\n") fmt.Printf("%s invalid project folder - %s\n\n", clifmt.Warn(), clifmt.Color(36, projectPath)) fmt.Printf("You must specify an existing directory path\n") return + } else { + fmt.Printf("ok\n") } /* (2) Controllers path */ + clifmt.Align(" . controllers") if stat, err := os.Stat(cPath); err != nil || !stat.IsDir() { - fmt.Printf("%s invalid controllers' folder - %s\n\n", clifmt.Warn(), clifmt.Color(36, cPath)) - fmt.Printf("You must specify an existing directory path\n") - return - } - /* (3) Types path */ - if stat, err := os.Stat(tPath); err != nil || !stat.IsDir() { - fmt.Printf("%s invalid types folder - %s\n\n", clifmt.Warn(), clifmt.Color(36, tPath)) - fmt.Printf("You must specify an existing directory path\n") - return + compileControllers = false + fmt.Printf("missing\n") + } else { + fmt.Printf("ok\n") } - fmt.Printf("%s\n", projectPath) - fmt.Printf("%s\n", cPath) - fmt.Printf("%s\n", tPath) + /* (3) Types path */ + clifmt.Align(" . custom types") + if stat, err := os.Stat(tPath); err != nil || !stat.IsDir() { + fmt.Printf("missing\n") + compileTypes = false + + } else { + fmt.Printf("ok\n") + } + + if !compileControllers && !compileTypes { + fmt.Printf("\n%s\n", clifmt.Info("Nothing to compile")) + return + } }