gouick/cmd/generateMakefile.go
Matthieu 'JP' DERASSE 5f4e7e5be6
All checks were successful
continuous-integration/drone/push Build is passing
fix(global): Multiple small fixes and upgrade of go + goswagger
2022-11-21 18:40:39 +00:00

47 lines
1.0 KiB
Go

/*
Copyright © 2022 Matthieu Derasse <git@derasse.fr>
*/
package cmd
import (
"git.home.m-and-m.ovh/mderasse/gouick/helpers/api_types"
"github.com/spf13/cobra"
log "github.com/sirupsen/logrus"
)
// makefileCmd represents the makefile command.
var makefileCmd = &cobra.Command{
Use: "makefile",
Short: "Generate Makefile",
Run: runGenerateMakefile,
}
func init() {
generateCmd.AddCommand(makefileCmd)
}
// runGenerateMakefile will generate the Makefile for the current project.
func runGenerateMakefile(cmd *cobra.Command, args []string) {
log.Debugf("Starting command GenerateMakefile")
currentPath, config, err := loadProjectAndConfig()
if err != nil {
return
}
apiType, err := api_types.GetAPIType(config.ProjectType)
if err != nil {
log.Error("Impossible to load that API Type generator")
return
}
// Generate Makefile
log.Info("Generating Makefile")
err = apiType.GenerateMakefile(currentPath, config)
if err != nil {
log.Errorf("Fail to generate Makefile. The following error happen: %s", err.Error())
return
}
}