feat(init): Get User input for config + small refacto
This commit is contained in:
7
helpers/models/api_type.go
Normal file
7
helpers/models/api_type.go
Normal file
@ -0,0 +1,7 @@
|
||||
package models
|
||||
|
||||
// UserInputParams
|
||||
type UserInputParams struct {
|
||||
GoModuleName *string
|
||||
DB bool
|
||||
}
|
70
helpers/models/api_type_name_enum.go
Normal file
70
helpers/models/api_type_name_enum.go
Normal file
@ -0,0 +1,70 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/juju/errors"
|
||||
)
|
||||
|
||||
// ApiTypeName
|
||||
type ApiTypeName string
|
||||
|
||||
const (
|
||||
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_GIN_GONIC,
|
||||
ApyTypeName_GO_SWAGGER,
|
||||
ApyTypeName_MOJOLICIOUS,
|
||||
}
|
||||
}
|
||||
|
||||
// IsValid validates enum values
|
||||
func (e ApiTypeName) IsValid() bool {
|
||||
for _, v := range GetListOfApiTypeName() {
|
||||
if e == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func NewApiTypeName(in string) (ApiTypeName, error) {
|
||||
out := ApyTypeName_NULL
|
||||
if in != "" {
|
||||
out = ApiTypeName(in)
|
||||
if !out.IsValid() {
|
||||
return ApyTypeName_NULL, errors.BadRequestf("Value %s invalid for enum ApiTypeName", in)
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// NewApiTypeNameFromInput
|
||||
func NewApiTypeNameFromInput(in string) (ApiTypeName, error) {
|
||||
|
||||
in = strings.ToLower(in)
|
||||
in = strings.ReplaceAll(in, " ", "-")
|
||||
in = strings.ReplaceAll(in, "_", "-")
|
||||
|
||||
out := ApyTypeName_NULL
|
||||
if in != "" {
|
||||
for _, apiTypeName := range GetListOfApiTypeName() {
|
||||
apiTypeStr := strings.ToLower(string(apiTypeName))
|
||||
apiTypeStr = strings.ReplaceAll(apiTypeStr, " ", "-")
|
||||
apiTypeStr = strings.ReplaceAll(apiTypeStr, "_", "-")
|
||||
if in == apiTypeStr {
|
||||
return apiTypeName, nil
|
||||
}
|
||||
}
|
||||
return ApyTypeName_NULL, errors.BadRequestf("Value %s invalid for enum ApiTypeName", in)
|
||||
}
|
||||
return out, nil
|
||||
}
|
10
helpers/models/dependency_name_enum.go
Normal file
10
helpers/models/dependency_name_enum.go
Normal file
@ -0,0 +1,10 @@
|
||||
package models
|
||||
|
||||
// DependencyName
|
||||
type DependencyName string
|
||||
|
||||
const (
|
||||
DependencyName_GIT DependencyName = "Git"
|
||||
DependencyName_GOLANG DependencyName = "Golang"
|
||||
DependencyName_GO_SWAGGER DependencyName = "Go Swagger"
|
||||
)
|
Reference in New Issue
Block a user