compile.go 850 B

123456789101112131415161718192021222324252627282930313233
  1. package commands
  2. import (
  3. "fmt"
  4. . "git.eugeniocarvalho.dev/eugeniucarvalho/apicodegen/common"
  5. "git.eugeniocarvalho.dev/eugeniucarvalho/apicodegen/flag"
  6. . "git.eugeniocarvalho.dev/eugeniucarvalho/apicodegen/gen"
  7. "github.com/davecgh/go-spew/spew"
  8. )
  9. func compile() (err error) {
  10. var project *Project
  11. fmt.Println("COMPILE WITH SETUP...", *flag.Mode, *flag.BuildProfile, *flag.Out)
  12. // Cria um novo projeto a partir do diretorio atual
  13. if project, err = CreateProject(); err != nil {
  14. panic(err)
  15. }
  16. // Executa a geracao de codigo para o projeto
  17. if err = project.Build(&BuildOptions{
  18. Mode: *flag.BuildProfile,
  19. }); err != nil {
  20. spew.Dump(err)
  21. panic(err)
  22. }
  23. // Salva o json contendo a descricao completa do projeto
  24. // if err = project.Save(fmt.Sprintf("%s/project.gen.json", *flag.Out)); err != nil {
  25. // panic(err)
  26. // }
  27. return
  28. }