feat(init): Get User input for config + small refacto
This commit is contained in:
21
cmd/init.go
21
cmd/init.go
@ -8,10 +8,13 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/api_type"
|
||||
"github.com/juju/errors"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/api_types"
|
||||
"git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@ -87,7 +90,7 @@ func runInitAction(cmd *cobra.Command, args []string) {
|
||||
|
||||
// ask which API type we want to use
|
||||
var possibleApiTypes []string
|
||||
for _, apiType := range api_type.GetListOfApiTypeName() {
|
||||
for _, apiType := range models.GetListOfApiTypeName() {
|
||||
possibleApiTypes = append(possibleApiTypes, string(apiType))
|
||||
}
|
||||
|
||||
@ -96,11 +99,21 @@ func runInitAction(cmd *cobra.Command, args []string) {
|
||||
|
||||
log.Debugf("Using api type : %s", string(apiTypeName))
|
||||
|
||||
_, err = api_type.GetApiType(apiTypeName)
|
||||
apiType, err := api_types.GetApiType(apiTypeName)
|
||||
if err != nil {
|
||||
log.Error("Impossible to load that API Type generator")
|
||||
}
|
||||
|
||||
// XXX: split in to: checkBeforeInitialize + GetInitializeUserInput
|
||||
// launch GetInitializeUserInput from selected api type
|
||||
log.Debug("Get user input for the selected API type")
|
||||
|
||||
_, err = apiType.GetInitializeUserInput()
|
||||
if err != nil && !errors.Is(err, errors.NotImplemented) {
|
||||
log.Errorf("Fail to get all the required input. The following error happen: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// XXX:
|
||||
// Check we are in gopath or ask for the gomod name
|
||||
// Create directory
|
||||
|
Reference in New Issue
Block a user