add formatting + check which (controllers, types) to compile

This commit is contained in:
Adrien Marquès 2018-07-07 12:58:46 +02:00
parent f3b442e810
commit d9460952ab
1 changed files with 27 additions and 12 deletions

View File

@ -27,6 +27,8 @@ func main() {
return return
} }
var projectPathFlag = flag.Arg(0) var projectPathFlag = flag.Arg(0)
compileTypes := true
compileControllers := true
/* (2) Get absolute paths /* (2) Get absolute paths
---------------------------------------------------------*/ ---------------------------------------------------------*/
@ -58,28 +60,41 @@ func main() {
/* (3) Check path are existing dirs /* (3) Check path are existing dirs
---------------------------------------------------------*/ ---------------------------------------------------------*/
clifmt.Title("Check files")
/* (1) Project path */ /* (1) Project path */
clifmt.Align(" . project root")
if stat, err := os.Stat(projectPath); err != nil || !stat.IsDir() { 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("%s invalid project folder - %s\n\n", clifmt.Warn(), clifmt.Color(36, projectPath))
fmt.Printf("You must specify an existing directory path\n") fmt.Printf("You must specify an existing directory path\n")
return return
} else {
fmt.Printf("ok\n")
} }
/* (2) Controllers path */ /* (2) Controllers path */
clifmt.Align(" . controllers")
if stat, err := os.Stat(cPath); err != nil || !stat.IsDir() { 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)) compileControllers = false
fmt.Printf("You must specify an existing directory path\n") fmt.Printf("missing\n")
return } else {
} fmt.Printf("ok\n")
/* (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
} }
fmt.Printf("%s\n", projectPath) /* (3) Types path */
fmt.Printf("%s\n", cPath) clifmt.Align(" . custom types")
fmt.Printf("%s\n", tPath) 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
}
} }