fix(clean): Fix import order, func name, ...
This commit is contained in:
parent
f7e9aa7dfb
commit
a3c953c7a4
10
cmd/init.go
10
cmd/init.go
@ -92,9 +92,15 @@ func runInitAction(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
|
||||
log.Infof("Which kind of API do you want to init (possible values: %s)", strings.Join(possibleApiTypes, ", "))
|
||||
apiType := helpers.ApiTypeInput()
|
||||
apiTypeName := helpers.ApiTypeNameInput()
|
||||
|
||||
log.Debugf("Using api type : %s", string(apiTypeName))
|
||||
|
||||
_, err = api_type.GetApiType(apiTypeName)
|
||||
if err != nil {
|
||||
log.Error("Impossible to load that API Type generator")
|
||||
}
|
||||
|
||||
log.Debugf("Using api type : %s", apiType)
|
||||
// XXX:
|
||||
// Check we are in gopath or ask for the gomod name
|
||||
// Create directory
|
||||
|
@ -1,6 +1,12 @@
|
||||
package api_type
|
||||
|
||||
import "github.com/juju/errors"
|
||||
import (
|
||||
"github.com/juju/errors"
|
||||
|
||||
"git.home.m-and-m.ovh/mderasse/boot/helpers/api_type/gin_gonic"
|
||||
"git.home.m-and-m.ovh/mderasse/boot/helpers/api_type/go_swagger"
|
||||
"git.home.m-and-m.ovh/mderasse/boot/helpers/api_type/mojolicious"
|
||||
)
|
||||
|
||||
func GetApiType(in ApiTypeName) (ApiTypeInterface, error) {
|
||||
if in == "" {
|
||||
@ -13,8 +19,12 @@ func GetApiType(in ApiTypeName) (ApiTypeInterface, error) {
|
||||
|
||||
switch in {
|
||||
case ApyTypeName_GIN_GONIC:
|
||||
return gin_gonic.ApiType{}, nil
|
||||
case ApyTypeName_GO_SWAGGER:
|
||||
return go_swagger.ApiType{}, nil
|
||||
case ApyTypeName_MOJOLICIOUS:
|
||||
return mojolicious.ApiType{}, nil
|
||||
}
|
||||
|
||||
return nil, errors.NotFoundf("Unknown Api Type")
|
||||
}
|
||||
|
@ -10,17 +10,17 @@ import (
|
||||
type ApiTypeName string
|
||||
|
||||
const (
|
||||
ApyTypeName_NULL ApiTypeName = ""
|
||||
ApyTypeName_GO_SWAGGER ApiTypeName = "Go Swagger"
|
||||
ApyTypeName_GIN_GONIC ApiTypeName = "Gin Gonic"
|
||||
ApyTypeName_GO_SWAGGER ApiTypeName = "Go Swagger"
|
||||
ApyTypeName_MOJOLICIOUS ApiTypeName = "Mojolicious"
|
||||
ApyTypeName_NULL ApiTypeName = ""
|
||||
)
|
||||
|
||||
// GetListOfApiTypeName returns a list of ApiTypeName
|
||||
func GetListOfApiTypeName() []ApiTypeName {
|
||||
return []ApiTypeName{
|
||||
ApyTypeName_GO_SWAGGER,
|
||||
ApyTypeName_GIN_GONIC,
|
||||
ApyTypeName_GO_SWAGGER,
|
||||
ApyTypeName_MOJOLICIOUS,
|
||||
}
|
||||
}
|
||||
@ -47,7 +47,8 @@ func NewApiTypeName(in string) (ApiTypeName, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewApiTypeFromInput(in string) (ApiTypeName, error) {
|
||||
// NewApiTypeNameFromInput
|
||||
func NewApiTypeNameFromInput(in string) (ApiTypeName, error) {
|
||||
|
||||
in = strings.ToLower(in)
|
||||
in = strings.ReplaceAll(in, " ", "-")
|
||||
|
@ -1,5 +1,8 @@
|
||||
package base
|
||||
package gin_gonic
|
||||
|
||||
import "git.home.m-and-m.ovh/mderasse/boot/helpers/api_type/base"
|
||||
|
||||
// ApiType
|
||||
type ApiType struct {
|
||||
base.ApiType
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"git.home.m-and-m.ovh/mderasse/boot/helpers/api_type"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@ -54,8 +55,8 @@ func PathInput() string {
|
||||
}
|
||||
}
|
||||
|
||||
// ApiTypeInput
|
||||
func ApiTypeInput() api_type.ApiTypeName {
|
||||
// ApiTypeNameInput
|
||||
func ApiTypeNameInput() api_type.ApiTypeName {
|
||||
|
||||
var possibleApiTypes []string
|
||||
for _, apiType := range api_type.GetListOfApiTypeName() {
|
||||
@ -68,7 +69,7 @@ func ApiTypeInput() api_type.ApiTypeName {
|
||||
scanner.Scan()
|
||||
userInput := scanner.Text()
|
||||
|
||||
apiTypeName, err := api_type.NewApiTypeFromInput(userInput)
|
||||
apiTypeName, err := api_type.NewApiTypeNameFromInput(userInput)
|
||||
if err != nil {
|
||||
log.Warnf("invalid API type (possible values: %s)", strings.Join(possibleApiTypes, ", "))
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user