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 (
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
// initCmd represents the init command
|
|
|
|
var initCmd = &cobra.Command{
|
|
|
|
Use: "init",
|
|
|
|
Short: "Initialize a new project",
|
|
|
|
Long: `Initialize a new project by creating a new directory and:
|
|
|
|
- Initialize a Git Repository
|
|
|
|
- Create a Go-Swagger Struct
|
|
|
|
- Add default routes
|
|
|
|
- Generate the API.
|
|
|
|
|
|
|
|
That command is Interactive or can be control through args`,
|
|
|
|
Run: runInitAction,
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
rootCmd.AddCommand(initCmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
func runInitAction(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
|
|
log.Debugf("Starting command Init")
|
|
|
|
|
|
|
|
log.Debugf("Checking dependecies")
|
|
|
|
|
|
|
|
// isDependeciesOk, err := helpers.CheckDependencies()
|
|
|
|
// if err != nil {
|
|
|
|
// log.Error(err.Error())
|
|
|
|
// return
|
|
|
|
// } else if isDependeciesOk {
|
|
|
|
// log.Error("Dependencies are not repescted")
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if isGoProject, err := helpers.IsGoProject(); err != nil {
|
|
|
|
// log.Error("An error occured when checking your directory.")
|
|
|
|
// return
|
|
|
|
// } else if isGoProject {
|
|
|
|
// log.Error("Cannot initialize a new project because you are already in a Golang Project Directory.")
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if isStrapProject, err := helpers.IsStrapProject(); err != nil {
|
|
|
|
// log.Error("An error occured when checking your directory.")
|
|
|
|
// return
|
|
|
|
// } else if isStrapProject {
|
|
|
|
// log.Error("Cannot initialize a new project because you are already in a Strap Project Directory.")
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
}
|