gouick/cmd/generateLauncher.go

47 lines
1.1 KiB
Go
Raw Permalink Normal View History

/*
Copyright © 2022 Matthieu Derasse <git@derasse.fr>
*/
package cmd
import (
"git.dev.m-and-m.ovh/mderasse/gouick/helpers/api_types"
"github.com/spf13/cobra"
log "github.com/sirupsen/logrus"
)
// launcherCmd represents the launcher command.
var launcherCmd = &cobra.Command{
Use: "launcher",
Short: "Generate Launcher entrypoint bash script",
Run: runGenerateLauncher,
}
func init() {
generateCmd.AddCommand(launcherCmd)
}
// runGenerateLauncher will generate the entrypoint for the current project.
func runGenerateLauncher(cmd *cobra.Command, args []string) {
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
}
}