2022-07-15 11:49:53 +00:00
|
|
|
/*
|
2022-07-16 15:46:09 +00:00
|
|
|
Copyright © 2022 Matthieu Derasse <git@derasse.fr>
|
2022-07-15 11:49:53 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2022-09-20 21:49:37 +00:00
|
|
|
"git.home.m-and-m.ovh/mderasse/gouick/helpers/api_types"
|
2022-07-15 11:49:53 +00:00
|
|
|
"github.com/spf13/cobra"
|
2022-09-20 21:49:37 +00:00
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
2022-07-15 11:49:53 +00:00
|
|
|
)
|
|
|
|
|
2022-08-03 11:17:15 +00:00
|
|
|
// launcherCmd represents the launcher command.
|
2022-07-15 11:49:53 +00:00
|
|
|
var launcherCmd = &cobra.Command{
|
|
|
|
Use: "launcher",
|
2022-09-20 21:49:37 +00:00
|
|
|
Short: "Generate Launcher entrypoint bash script",
|
2022-11-11 17:52:44 +00:00
|
|
|
Run: runGenerateLauncher,
|
2022-07-15 11:49:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
generateCmd.AddCommand(launcherCmd)
|
|
|
|
}
|
2022-09-20 21:49:37 +00:00
|
|
|
|
2022-11-11 17:52:44 +00:00
|
|
|
// runGenerateLauncher will generate the entrypoint for the current project.
|
|
|
|
func runGenerateLauncher(cmd *cobra.Command, args []string) {
|
2022-09-20 21:49:37 +00:00
|
|
|
log.Debugf("Starting command GenerateLauncher")
|
|
|
|
|
|
|
|
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 Launcher
|
|
|
|
log.Info("Generating Launcher")
|
|
|
|
err = apiType.GenerateLauncher(currentPath, config)
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("Fail to generate Launcher. The following error happen: %s", err.Error())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|